now that I am able to insert documents to my local Mongo, make some queries and display the resulting documents into a LiveCode Data Grid, I considered continue with some validation, begining with the simple verification of duplicate _ids. I saw that as espected, Mongo refuses to insert documents with duplicate ids, the problem is how to detect this situation.
I thought I have to somehow I got to check getLastError
or something Mongo reports from the insert operation success.
To do this, I add some code to my Insert button:
put "db.runCommand( { getLastError:" & "'" & 1 & "' ," & "w : " & "'" & 1 & "' })" into dbErr
put shell ( theMongo & theDB && "--eval" && quote & dbErr & quote) into dbResultado
Then I pass dbResultado
to the function JSONToArray(tJSON)
, but I get error
button "Insert Doc": execution error at line n/a (External handler: exception) near "could not decode JSON: invalid token near 'object'"
I think dbResultado is a JSON because when I put
it in the message, it gets:
MongoDB shell version: 2.2.7
connecting to: localhost:27017/BatGar
[object bson_object]
Maybe I am trying something that I shouldn't and there is other way of getting the error from Mongo to later operate based on it.