I have the following document schema:
var pageSchema = new Schema({
name: String
, desc: String
, url: String
})
Now, in my application I would like to also have the html source of the page inside the object, but I do not want to store it in the db.
Should I create a "local" enhanced object which has a reference to the db document?
function Page (docModel, html) {
this._docModel = docModel
this._html = html
}
Is there a way to use the document model directly by adding a "virtual" field?
document.prop = html
. I don't think that method or virtuals will actually let you fetch "local" data if you fetch the object from the db again though, even if not restarting. – Trotylpage.newProperty = "something"; console.log(page)
it does not show thenewProperty
in the output.. but if I doconsole.log(page.newProperty)
I see the value :| – Mel