It looks like the Save function keeps track of the actual date and time of a save and that is used when the document is merged versus the sequency or _rev? Is that correct?
function save(db, doc) {
delete(doc._rev); // delete any revision numbers copied from previous docs
doc.$createdAt = (new Date()).toJSON();
if (doc.$id) { // update?
// this format guarantees the docs will be retrieved in order they were created
doc._id = doc.$id + '_' + doc.$createdAt;
return db.put(doc).then(function (response) {
response.$id = doc.$id;
return response;
})["catch"](/* istanbul ignore next */ function (err) {
// It appears there is a bug in pouch that causes a doc conflict even though we are creating a
// new doc
if (err.status !== 409) {
throw err;
}
});
} else { // new
return db.post(doc).then(function (response) {
response.$id = response.id;
return response;
});
}
}
It looks like the Save function keeps track of the actual date and time of a save and that is used when the document is merged versus the sequency or _rev? Is that correct?