Skip to content

Instantly share code, notes, and snippets.

@ritch
Created May 1, 2012 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ritch/2568271 to your computer and use it in GitHub Desktop.
Save ritch/2568271 to your computer and use it in GitHub Desktop.
dpd client api
// get all widgets
dpd.widgets.get(function (err, widgets) {
if(err) return alert(err);
console.log(widgets); // [Object, Object, Object, ...]
})
// get one widget
dpd.widgets.first(function (err, widget) {
if(err) return alert(err);
console.log(widget);
})
// save a new widget
dpd.widgets.save({name: 'my shiny new widget'}, function (err, savedWidget) {
console.log(err || savedWidget); // err or {_id: ..., name: ...}
})
// update an existing widget
dpd.widgets.save({_id: myId, name: 'my updated widget'}, function (err, savedWidget) {
console.log(err || savedWidget); // err or {_id: ..., name: ...}
})
// delete a widget
dpd.widgets.del({_id: myId}, function (err) {
console.log(err || 'it was deleted!');
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment