Releases: CodeYellowBV/mobx-spine
v0.13.0
- Breaking change: throw error when an observable and a relation have the same name. This did work before, but could lead to very strange bugs.
- Add models sorting with a
comparator
;
store.comparator = 'name'; // To sort on `name` attr on models
store.sort(); // To trigger a manual re-sort
store.comparator = (a, b) => (a.id - b.id); // Pass function for more complex sorting
- Make it easy to disable/modify snake <-> camel case converting of attribute keys. If you have a backend that does use e.g. camelCasing, you can disable this conversion by adding this to your model:
toBackendAttrKey(attrKey) { return attrKey; }
fromBackendAttrKey(attrKey) { return attrKey; }
v0.12.0
- Adds a new
store.virtualStore()
method, so you can filter on a store while keeping a store instance. All data from the new store will be kept in sync with the original store. It is inspired by backbone-virtual-collection.
const animals = AnimalStore();
const animalsWithOwners = animalStore.virtualStore({
filter: model => !!model.owner,
});
-
Adds a new
model.saveFromBackend()
method, use it e.g. when the backend doesn't return the model after callingmodel.save()
. Sometimes the model is created async in the backend so you can't parse the response (or you want to modify it). -
Binder API only: when a relation is camelCased, the request to the backend was not parsed to snake_case (
?with=pastOwners
instead of?with=past_owners
). -
Breaking change:
model.saveAll()
doesn't save all relations by default now, you need to specifically include the relations you want (model.saveAll({ relations: ['owner'] })
.
v0.11.4
v0.11.3
v0.11.2
v0.11.1
v0.11.0
v0.10.0
v0.9.0
When using model.toBackendAll()
, the name of the relation is sometimes
not the same as the name of the model or store. e.g.
relations() {
return { activities: ActivityStore };
}
But the backend knows the activities
relation by the name activity
.
To fix this, you can now set backendResourceName
on a model or store:
class ActivityStore extends Store {
static backendResourceName = 'activity';
}
v0.8.0
- A model now has a
cid
property, which is a globally unique value. You can use this e.g. in React in thekey
prop. - Allow newer versions of
axios
. - Use
pkg.module
instead ofpkg.browser
inpackage.json
, since support for that is better apparently. - Allow custom versions of moment to be used as property (e.g. a version with custom locales).