Duque Active Member Licensed User Longtime User Nov 13, 2024 #1 Hi, I hope you can give me a hand. Inserting a document into a MongoDB collection: Main.db.GetCollection(collection).Insert(documentList) I hope to get the last inserted ObjectId... How is it done?
Hi, I hope you can give me a hand. Inserting a document into a MongoDB collection: Main.db.GetCollection(collection).Insert(documentList) I hope to get the last inserted ObjectId... How is it done?
Erel B4X founder Staff member Licensed User Longtime User Nov 14, 2024 #2 I haven't touched MongoDB for a very long time, check this answer: https://stackoverflow.com/a/23077318/971547 Upvote 0
I haven't touched MongoDB for a very long time, check this answer: https://stackoverflow.com/a/23077318/971547
Duque Active Member Licensed User Longtime User Nov 14, 2024 #3 In short, I need to find the last sorted id and limit it to 1. Upvote 0
teddybear Well-Known Member Licensed User Nov 15, 2024 #4 Duque said: In short, I need to find the last sorted id and limit it to 1. Click to expand... Is it you want? B4X: Dim res As List = Main.db.GetCollection(collection).Find2(Null, Null, CreateMap("_id":-1),0,1) Log(res.Get(0)) Upvote 1
Duque said: In short, I need to find the last sorted id and limit it to 1. Click to expand... Is it you want? B4X: Dim res As List = Main.db.GetCollection(collection).Find2(Null, Null, CreateMap("_id":-1),0,1) Log(res.Get(0))