Skip to content

Commit aa5d306

Browse files
Merge pull request #955 from singnet/masc/redismongo-add-index
[#958] Replace insert_one() with upsert_document()
2 parents dd680fe + b3df1bf commit aa5d306

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/atomdb/redis_mongodb/RedisMongoDB.cc

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,18 +1154,13 @@ void RedisMongoDB::add_pattern_index_schema(const string& tokens,
11541154
index_entries_array.append(index_entry_array);
11551155
}
11561156

1157-
auto conn = this->mongodb_pool->acquire();
1158-
auto mongodb_collection = (*conn)[MONGODB_DB_NAME][MONGODB_PATTERN_INDEX_SCHEMA_COLLECTION_NAME];
1159-
1160-
auto reply = mongodb_collection.insert_one(bsoncxx::v_noabi::builder::basic::make_document(
1157+
auto document = bsoncxx::v_noabi::builder::basic::make_document(
11611158
bsoncxx::v_noabi::builder::basic::kvp(MONGODB_FIELD_NAME[MONGODB_FIELD::ID], id),
11621159
bsoncxx::v_noabi::builder::basic::kvp("tokens", tokens),
11631160
bsoncxx::v_noabi::builder::basic::kvp("priority", this->pattern_index_schema_next_priority),
1164-
bsoncxx::v_noabi::builder::basic::kvp("index_entries", index_entries_array)));
1161+
bsoncxx::v_noabi::builder::basic::kvp("index_entries", index_entries_array));
11651162

1166-
if (!reply) {
1167-
Utils::error("Failed to insert pattern index schema into MongoDB");
1168-
}
1163+
this->upsert_document(document, MONGODB_PATTERN_INDEX_SCHEMA_COLLECTION_NAME);
11691164

11701165
this->pattern_index_schema_map[this->pattern_index_schema_next_priority] =
11711166
make_tuple(move(tokens_vector), index_entries);

0 commit comments

Comments
 (0)