To be clear, this issue is related to loading data from the database, not updating documents in the database.
With the following diagram:
new mongoose.Schema name: String code: type: String index: unique: true _contacts: [ type: mongoose.Schema.Types.ObjectId ref: 'Person' ]
I created my document as follows:
client = new Client code:'test',name:'test competition',contacts:[] client.save()
Elsewhere in the application or through an API call, somewhere that it cannot easily reference the version cached above:
Client.findOne(code:'test').exec (err,client) -> return if err or not client client._contacts.push person.id
If we go back to our original client object, I would like to know if there is a way to update this object either for the entire document, or only for a specific path. For example,
client.refresh '_contacts', (err) -> return err if err
Or would it be better to support only one object, which is called globally?
chrisbateskeegan
source share