Skip to content

Instantly share code, notes, and snippets.

@jrf0110
Created May 7, 2015 20:22
Show Gist options
  • Save jrf0110/6328ee16a5713dc9ee30 to your computer and use it in GitHub Desktop.
Save jrf0110/6328ee16a5713dc9ee30 to your computer and use it in GitHub Desktop.
var tx = dirac.tx.create();
utils.async.series([
tx.begin.bind( tx )
// Remove items
, tx.payment_summary_items.remove.bind(
tx.payment_summary_items
, { payment_summary_id: $where.id }
)
// Add items
, items.length > 0
? tx.payment_summary_items.insert.bind(
tx.payment_summary_items
, items
)
: utils.async.noop
// Update the original document
, Object.keys( $update ).length > 0
? tx.payment_summaries.update.bind(
tx.payment_summaries
, $where
, $update
, options
)
: utils.async.noop
, tx.commit.bind( tx )
], callback );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment