These are chat archives for Automattic/mongoose

6th
Jun 2015
Fayi Femi-Balogun
@fayimora
Jun 06 2015 10:04
is this the right was to define embedding in mongoose? https://gist.github.com/fayimora/94213d1322ad4a8d66bd
priceDetails should be an embedded doc/object. I was wondering why I can't just do priceDetails: PriceDetails
Erinç Fırtına
@EricMcRay
Jun 06 2015 11:53
@fayimora you can do it like priceDetails: PriceDetailsSchema
Fayi Femi-Balogun
@fayimora
Jun 06 2015 11:56
@EricMcRay thanks. Soo when do i do that whole ref thing? when i want a foreign key?
Erinç Fırtına
@EricMcRay
Jun 06 2015 11:57
@vkarpov15 my schema is like this:
new Schema({ username: String, salt: { type: String, select: 0}, hashedPassword: { type: String, select: 0} })
And my query is like:
User.find({}, '+salt +hashedPassword')
also tried these too:
User.find({}, 'salt hashedPassword') User.find({}).select('salt').exec()
@fayimora you can use many to many or one to many relations. for one to one relation you can use nesting document
Fayi Femi-Balogun
@fayimora
Jun 06 2015 12:07
@EricMcRay makes sense thanks
Erinç Fırtına
@EricMcRay
Jun 06 2015 12:08
@fayimora you welcome
Fayi Femi-Balogun
@fayimora
Jun 06 2015 17:20
i updated a record with a field that is not defined in the schema. However, the db record wasn't updated accordingly. any idea why? I know i have a schema but is it strict? i thought i could add fields in demand
*fields on demand
Jake Forrester
@rannmann
Jun 06 2015 20:21
"The strict option, (enabled by default), ensures that values passed to our model constructor that were not specified in our schema do not get saved to the db."
Fayi Femi-Balogun
@fayimora
Jun 06 2015 20:37
@rannmann how do i disable this? or is it a bad idea?