oomph
Version:
Object Oriented javascript models for the client and the server
17 lines (13 loc) • 572 B
text/coffeescript
ajaxObjectClassDataStore = require '../privateModules/ajaxObjectClassDataStore'
ajaxObjectInstanceDataStore =
save: ->
if
updateFields = {}
for attr in Object.keys(.attributes)
updateFields[attr] = this[attr] if this[attr]
ajaxObjectClassDataStore.update.apply(, [, updateFields]).then (newProps) =>
_.assign(this, newProps)
else
ajaxObjectClassDataStore.create.apply(, [this]).then (newProps) =>
_.assign(this, newProps)
module.exports = ajaxObjectInstanceDataStore