These are chat archives for Automattic/mongoose

2nd
Jun 2016
Nick Rameau
@R4meau
Jun 02 2016 03:14
@LeonineKing1199 How would I do that? Can't find anything related to that on Google.
pdiogo
@PedroMD
Jun 02 2016 08:30
@R4meau something like:
Model.findById(id, function (err, doc) { doc.increment(); //do what you want with the fetched doc, before saving doc.save(function (err) { .. }) })
Nick Rameau
@R4meau
Jun 02 2016 08:32
@PedroMD alright. Thanks mate. Will try this later
pdiogo
@PedroMD
Jun 02 2016 08:32
np
levuphuong
@levuphuong
Jun 02 2016 09:32
hi
I have embedded asset_detail in doc.
My question is how to update something in asset_detail when i have asset.name (unique). Because i dont know how to get embedded doc id.
Thank you
var asset = { name: filename, type: "File", access: "private", status: "uploaded", location: filename } user.asset_detail.push(asset)
Charlie Davison
@charliedavison
Jun 02 2016 13:05
I'm getting confused about how to correctly manage my models between the client and the server. I have a bunch of mongoose models on the server side which I've seen can be used on the client based on the information here: http://mongoosejs.com/docs/unstable/docs/browser.html

The issue I'm having is that I have a schema that looks like this -

module.exports = {
Reference : { type: String, required: true },
PersonnelID: { type: schema.ObjectId },
ServiceType : { type: LookUpSchema },
Clinic : { type: LookUpSchema },
EarliestDate : { type: Date },
LatestDate : { type: Date },
Notes : { type: String }
}

which would be fine, but the schema.ObjectId's don't work because I'd need to require schema, which also means requiring mongoose, but I cant do this because requiring mongoose on the client side blows up in webpack
Mohamed Nasrullah
@nasr18
Jun 02 2016 13:43
i need to update my data. and it has an array field. if data already present it should skip that data and if not means, it should add to that array. how to do this???
Paul "Joey" Clark
@joeytwiddle
Jun 02 2016 13:45
@nasr18 I think you're looking for 'addToSet'
Mohamed Nasrullah
@nasr18
Jun 02 2016 13:46
nope its not
i will update number field, string field and array field. but if i add $addToSet along with other field means, its not working