node.js - Adding fields to model which derived from Mongoose schema -


I have a Monois schema that looks like this:

  ManifestSchema = new schema ({Entries: [{order_id: string, line_item: {}, // & lt; - resolved on run time address: {}, // <- resolved in run time Added: number, stop : Number,}]}, {collection: 'manifest', strict: true});  

And somewhere I have a code in:

  Q.ninvoke (Manifests.findById (req.params.id), 'exec'). Then (function (manifest) {// ... many things like addresses and item information entry resolving, entry.line_item = item; entry .address = order.delivery.address;})  

The problem I have encountered is that without defining the address and line_item in the schema, when I resolved them on time, they will not come back to the user because they were not in the schema ... so I added them ... by which I have another unwanted behavior R is: when I saved back to the object, both out and saved with Lain_itm Menist object, which is something I would like to save.

What field is not saving for the schema at the time, but still, on the way back?

I was trying to use 'virtual' in Mongos, but what do they actually provide me because I model from a schema, but it was returned from the database.

> "post-text" itemprop = "text">

To create a simple JavaScript copy on your manifest Mongoose instance, you can add additional fields For user feedback without the need to save the dock:

  Q.ninvoke (Manifests.findById (req.params.id), 'exec'). Then (function (manifest) {var manifestResponse = manifest.toObject (); // ... so many things, such as address address and item information entry. Line_item = item; Entry.address = order.delivery.address;} )  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -