Skip to content

Commit

Permalink
Merge pull request Fedox-die-Ente#5 from Fedox-die-Ente/renovate/mong…
Browse files Browse the repository at this point in the history
…odb-3.x

Update Rust crate mongodb to v3
  • Loading branch information
Austria7 committed Jul 4, 2024
2 parents b784bb4 + e7c8446 commit bcd1393
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ singlyton = "4.1.1"


[dependencies.mongodb]
version = "2.8.2"
features = ["tokio-runtime"]
version = "3.0.0"
18 changes: 9 additions & 9 deletions src/functions/mongodbcollection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub fn get_collection(l: LuaState) -> i32 {
let collection: mongodb::Collection<Document> = db.collection(collection_name);

let collection_list = MONGO_WORKER.block_on(async {
db.list_collection_names(None).await
db.list_collection_names().await
});

if collection_list.is_err() {
Expand All @@ -151,7 +151,7 @@ pub fn drop_collection(l: LuaState) -> i32 {
let collection_name = rstr!(luaL_checkstring(l, 2));

let collection_list = MONGO_WORKER.block_on(async {
db.list_collection_names(None).await
db.list_collection_names().await
});

if collection_list.is_err() {
Expand All @@ -167,7 +167,7 @@ pub fn drop_collection(l: LuaState) -> i32 {
}

MONGO_WORKER.block_on(async {
let _ = db.collection::<Document>(collection_name).drop(None).await;
let _ = db.collection::<Document>(collection_name).drop().await;
});

lua_pushboolean(l, true as i32);
Expand All @@ -181,7 +181,7 @@ pub fn create_collection(_l: LuaState) -> i32 {
let collection_name = rstr!(luaL_checkstring(_l, 2));

let collection_list = MONGO_WORKER.block_on(async {
db.list_collection_names(None).await
db.list_collection_names().await
});

if collection_list.is_err() {
Expand All @@ -195,7 +195,7 @@ pub fn create_collection(_l: LuaState) -> i32 {
}

let result = MONGO_WORKER.block_on(async {
db.create_collection(collection_name, None).await
db.create_collection(collection_name).await
});

if result.is_err() {
Expand Down Expand Up @@ -226,7 +226,7 @@ pub fn insert(l: LuaState) -> i32 {
};

let insert_result = MONGO_WORKER.block_on(async {
collection.insert_one(doc, None).await
collection.insert_one(doc).await
});

if let Err(err) = insert_result {
Expand Down Expand Up @@ -260,7 +260,7 @@ pub fn find(l: LuaState) -> i32 {
};

let find_result = MONGO_WORKER.block_on(async {
collection.find(Some(filter), None).await
collection.find(filter).await
});

if let Err(err) = find_result {
Expand Down Expand Up @@ -313,7 +313,7 @@ pub fn update(l: LuaState) -> i32 {
};

let update_result = MONGO_WORKER.block_on(async {
collection.update_many(filter, update, None).await
collection.update_many(filter, update).await
});

match update_result {
Expand Down Expand Up @@ -348,7 +348,7 @@ pub fn delete(l: LuaState) -> i32 {
};

let delete_result = MONGO_WORKER.block_on(async {
collection.delete_many(filter, None).await
collection.delete_many(filter).await
});

match delete_result {
Expand Down
6 changes: 3 additions & 3 deletions src/tests/mongo_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ mod tests {

let db = client.database("admin");

let _ = db.create_collection("testtest", None).await?;
let _ = db.create_collection("testtest").await?;
log(LogLevel::Info, "Collection created.");

let collection: Collection<TestType> = db.collection("testtest");
Expand All @@ -41,8 +41,8 @@ mod tests {
age: 20,
};

collection.insert_one(test, None).await.expect("Failed to insert");
collection.drop(None).await.expect("Failed to drop collection");
collection.insert_one(test).await.expect("Failed to insert");
collection.drop().await.expect("Failed to drop collection");

Ok(())
}
Expand Down

0 comments on commit bcd1393

Please sign in to comment.