Socket
Socket
Sign inDemoInstall

redux-orm

Package Overview
Dependencies
7
Maintainers
4
Versions
70
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install
Previous123467Next

0.6.0

Diff

Changelog

Source

0.6.0

Breaking changes:

  • When calling QuerySet.filter or QuerySet.exclude with an object argument, any values of that object that look like a Model instance (i.e. they have a getId property that is a function), will be turned into the id of that instance before performing the filtering or excluding.

E.g.

Book.filter({ author: Author.withId(0) });

Is equivalent to

Book.filter({ author: 0 });
tommikaikkonen
published 0.5.0 •

Changelog

Source

0.5.0

Breaking changes:

  • Model instance method equals(otherModel) now checks if the two model's attributes are shallow equal. Previously, it checked if the id's and model classes are equal.
  • Session constructor now receives a Schema instance as its first argument, instead of an array of Model classes (this only affects you if you're manually instantiating Sessions with the new operator).

Other changes:

  • Added hasId static method to the Model class. It tests for the existence of the supplied id in the model's state.
  • Added instance method getNextState to the Session class. This enables you to get the next state without running model-reducers. Useful if you're bootstrapping data, writing tests, or otherwise operating on the data outside reducers. You can pass an options object that currently accepts a runReducers key. It's value indicates if reducers should be run or not.
  • Improved API documentation.
tommikaikkonen
published 0.4.0 •

Changelog

Source

0.4.0

  • Fixed a bug that mutated props passed to Model constructors, which could be a reference from the state. I highly recommend updating from 0.3.1.
  • API cleanup, see breaking changes below.
  • Calling getNextState is no longer mandatory in your Model reducers. If your reducer returns undefined, getNextState will be called for you.

Breaking changes:

  • Removed static methods Model.setOrder() and Backend.order. If you want ordered entities, use the QuerySet instance method orderBy.
  • Added helpful error messages when trying to add a duplicate many-to-many entry (Model.someManyRelated.add(...)), trying to remove an unexisting many-to-many entry (Model.exampleManyRelated.remove(...)), or creating a Model with duplicate many-to-many entry ids (Model.create(...)).
  • Removed ability to supply a mapping function to QuerySet instance method update. If you need to record updates dynamically based on each entity, iterate through the objects with forEach and record updates separately:
const authors = publisher.authors;
authors.forEach(author => {
    const isAdult = author.age >= 18;
    author.update({ isAdult });
})

or use the ability to merge an object with all objects in a QuerySet. Since the update operation is batched for all objects in the QuerySet, it can be more performant with a large amount of entities:

const authors = publisher.authors;
const isAdult = author => author.age >= 18;

const adultAuthors = authors.filter(isAdult);
adultAuthors.update({ isAdult: true });

const youngAuthors = authors.exclude(isAdult);
youngAuthors.update({ isAdult: false });
tommikaikkonen
published 0.3.1 •

Changelog

Source

0.3.1

A descriptive error is now thrown when a reverse field conflicts with another field declaration. For example, the following schema:

class A extends Model {}
A.modelName = 'A';

class B extends Model {}
B.modelName = 'B';
B.fields = {
    field1: one('A'),
    field2: one('A'),
};

would try to define the reverse field b on A twice, throwing an error with an undescriptive message.

tommikaikkonen
published 0.3.0 •

Changelog

Source

0.3.0

Breaking changes:

  • Model.withId(id) now throws if object with id id does not exist in the database.
tommikaikkonen
published 0.2.0 •

Changelog

Source

0.2.0

Includes various bugfixes and improvements.

Breaking changes:

  • Replaced plain and models instance attributes in QuerySet with withRefs and withModels respectively. The attributes return a new QuerySet instead of modifying the existing one. A ref alias is also added for withRefs, so you can do Book.ref.at(2).
  • After calling filter, exclude or orderBy method on a QuerySet instance, the withRefs flag is always flipped off so that calling the same methods on the returned QuerySet would use model instances in the operations. Previously the flag value remained after calling those methods.
  • .toPlain() from QuerySet is renamed to .toRefArray() for clarity.
  • Added .toModelArray() method to QuerySet.
  • Removed .objects() method from QuerySet. Use .toRefArray() or .toModelArray() instead.
  • Removed .toPlain() method from Model, which returned a copy of the Model instance's property values. To replace that, ref instance getter was added. It returns a reference to the plain JavaScript object in the database. So you can do Book.withId(0).ref. If you need a copy, you can do Object.assign({}, Book.withId(0).ref).
  • Removed .fromEmpty() instance method from Schema.
  • Removed .setReducer() instance method from Schema. You can just do ModelClass.reducer = reducerFunc;.
tommikaikkonen
published 0.1.24 •

tommikaikkonen
published 0.1.23 •

tommikaikkonen
published 0.1.22 •

tommikaikkonen
published 0.1.21 •

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc