This commit is contained in:
Andris Reinman 2016-05-13 20:08:42 +03:00
parent 01fe8d0dbc
commit d933f07eac
4 changed files with 28 additions and 1 deletions

View file

@ -345,6 +345,24 @@ module.exports.insert = (listId, meta, subscription, callback) => {
statusDirection = !existing ? (meta.status === 1 ? '+' : '-') : (existing.status === 1 ? '-' : '+');
}
if (!keys.length) {
// nothing to update
return connection.commit(err => {
if (err) {
return connection.rollback(() => {
connection.release();
return callback(err);
});
}
connection.release();
return callback(null, {
entryId,
cid: meta.cid,
inserted: !existing
});
});
}
if (!existing) {
// insert as new
keys = insertKeys.concat(keys);