B4J Question MongoDB Find on _id return 0

rwblinn

Well-Known Member
Licensed User
Longtime User
Hi,

in exploring using the MongoDB created a testapp where the _id field is created by the MongoDB as not setting this field explicit. Each record gets its unique _id, which makes it easy to handle in f.e. a jQuery DataTable. The record has 3 fields _id, Name, URL.

When using
B4X:
FindID("581349d6ae77cd0be3837eb5")
Sub FindID(id As String)
   Dim filter As Map = CreateMap("_id":id)
   Dim l As List = mongoCol.Find(filter, Null, Null)
   Log($"Find Result: ${l.Size}"$)
End Sub
the resulting list is empty.
Tried also with id as Object, same result.
When filter set on field Name then result is ok (record found).

See test project attached - tests running on a Raspberry Pi.

Should the auto creation of the _id field be avoided?
Any help appreciated?
 

Attachments

  • Example4.zip
    1.3 KB · Views: 255

rwblinn

Well-Known Member
Licensed User
Longtime User
Thanks for clarity - confirmed working for all CRUD operations on a B4J HowTo WebApp Example running on a Raspberry Pi.
Will share soon.
upload_2016-10-28_16-29-25.png
 
Upvote 0
Top