Modifying Data

All data modifications should happen through the following add, remove and update methods.

Adding a row:

To add a row to your dataset, use the add method.

ds.add(rowObject, options);
You can edit the code in this block and rerun it.

Removing a Row:

To remove a row from your dataset, use the remove method. There are two ways to remove rows:

Updating Rows:

To update a row, pass the row object with the identifying id property and changed set of attributes, an array of objects of the same format or a function that will first be applied to all rows and then update the dataset using the changed set of rows. For example::

ds.update(rowsOrFunction, options);
For example:
  _id : 12, col1 : newVal, col2 : newVal ...

To update rows via a function pass a function that modifies each row in the dataset as it should change, or returns false if the row should not be altered. For example:

ds.update(function(row) {
  if (row.value % 2 === 0) {
    row.outcome = true;
    return row;
  } else {
    return false;


If you set sync : true when creating your dataset. The following events will be triggered:

Adding a row will trigger the following events in this order:

Either remove call will trigger the following events in this order:

A call to update will trigger the following events in this order:

You can always pass { silent : true } as the optional options parametere to suppress events. For more information about events, see the events tutorial.

« Events

Computed Values »