Models
AJAX Abstraction for a Single Resource
AJAX Abstraction for a Single Resource
The cidPrefix
property for "client id prefix", and is used for generating the cid
value for the model.
To see how it's used, see the docs for the generateCid()
method here.
The default implementation looks like this:
cidPrefix: 'c',
Whenever you create a model, it is assigned a cid
, which is generated using the cidPrefix
followed by an integer.
Let's use this code to illustrate:
import { Model } from 'lore-models';
const Tweet = Model.extend();
const t1 = new Tweet();
const t2 = new Tweet();
In the example above, t1
will have a cid
of c1
, and t2
will have a cid
of c2
.
If we want to change this, we can define a custom cidPrefix
like this:
import { Model } from 'lore-models';
const Tweet = Model.extend({
cidPrefix: 'tweet'
});
const t1 = new Tweet();
const t2 = new Tweet();
In the code above, we define a custom cidPrefix
declaring that all cid
values should begin with tweet
. This will mean t1
will now have a cid
of tweet1
, and t2
will now have a cid
of tweet2
.