These are chat archives for Automattic/mongoose

11th
Oct 2016
Paul "Joey" Clark
@joeytwiddle
Oct 11 2016 08:30
We put our enums in their own tiny module. Then the mongoose schema and the controllers can all require them. E.g.:
color: {type: Number, enum: Object.values( require(‘../const/colors’) )}
Joshua Bemenderfer
@JoshTheDerf
Oct 11 2016 17:57
Does Mongoose have any active plugins for automatically handling (create, read, update, delete, etc) one-many, and many-many relationships? Is it just me or is this a big gap in Mongoose's capabilities?
Right now we're using some hacky tricks on a base model to do so with intermediate tables, but it's proving to be pretty unstable.
Varun Jayaraman
@varunjayaraman
Oct 11 2016 21:28

is there a way to run the mongoose Document constructor on a POJO and preserve populated values (i.e. i populated the document on the server and sent it over to the client)? Whenever I instantiate a new mongoose document in the browser, like so:

new mongoose.Document(pojo, RandomSchema)

I lose the populated values