How do I add properties to a js-data object that I don't want persisted?

258 views Asked by At

I'm using js-data (and js-data-angular) in conjunction with sockets via sails.js. When a new item is created/updated via sockets I want to call attention to it in my ui.

I'd like to add an "updated" property to the object, but don't want to inadvertently persist it to the DB.

Is there a way to hang non-persisting properties on a js-data object?

2

There are 2 answers

0
diz On BEST ANSWER

Yes.

You can set this globally on the data store or per-resource by using the omit configuration setting. For instance, when instancing your data store, you can instruct JSData to ignore all properties that begin with an underscore:

var store = new JSData.DS({ omit: [ /^_/ ] });
0
epeleg On

The documentation for the meta property of the options passed to store.defineResource says:

Put anything you want here. It will never be used by the API.