loopback-connector-couch icon indicating copy to clipboard operation
loopback-connector-couch copied to clipboard

Missing `_rev` field when model `strict = true` causes `409 update conflict` errors

Open mhamann opened this issue 10 years ago • 0 comments

When calling instance.save() on an existing record, CouchDB returns a 409 Document update conflict when the model definition has the strict property set to true. It appears that BaseModel.applyProperties(data, instance) removes the _rev property because it isn't defined in the model.

I think the fix for this is figuring out a way for the DataSource to somehow inject any attached models with a hidden property to hold the _rev, because otherwise the default loopback functionality will automatically discard it. I'll look into this more as I'm able to find time.

For now, a workaround seems to be either manually adding _rev to the model's properties, and then setting _rev as a hidden property (i.e. hidden: ['_rev']), or just setting strict:false.

mhamann avatar May 16 '15 21:05 mhamann