mardi 12 novembre 2019

Implementing automatic counters in Eloquent MongoDB

I need some automatic counters that must be updated automatically. Is there a way to do this with Eloquent? I know that this can be implemented on MongoDB like so:

doc = { name : "order_no", value : 1}

db.Counters.save(doc)
db.Counters.findAndModify({query : { name : "order_no"}, update : { $inc : {value : 1}}, new: true})

How can I implement the last line using Eloquent/Jenssenger query builder?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire