Ok, I think I am getting close. This solution works but I am bypassing Loopback and the "mongoDB connector". Here is what I am doing.
Given a model named Sequence that looks like this:
{
"_id": {
"$oid": "54ab3ec0cc074e24144f26d7"
},
"collection": "SpecialOrder",
"value": 113
}
I am doing this:
mongoConnector = app.dataSources.MyMongoDBConnectorName.connector;
mongoConnector.collection("Sequence").findAndModify({collection: 'SpecialOrder'}, [['_id','asc']], {$inc: { value: 1 }}, {new: true}, function(err, sequence) {
if(err) {
console.log(err.message);
} else {
// Do what I need to do with new incremented value sequence.value
}
});
Like I said, this is working, but I am still not sure if it is the correct way of doing it. Seems like there should be a built in LoopbackJS way.
Thanks,
Warren Bell