Skip to content

Instantly share code, notes, and snippets.

@benbahrenburg
Last active Aug 29, 2015
Embed
What would you like to do?
Note Table - Update Script
function update(item, user, request) {
var table = tables.getTable('notes');
table.where({
id: item.id, userId : user.userId
}).read({
success: upsertItem
});
function upsertItem(items) {
item.userId = user.userId;
if (items.length > 0) {
request.execute();
} else {
table.insert(item, {
success: function(e) {
request.respond(statusCodes.OK, e)
}
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment