Skip to content

v0.6.0

Compare
Choose a tag to compare
@codebryo codebryo released this 13 Mar 18:36
· 32 commits to master since this release

This version extends Modelist we two new functionalities:

A new findBy method:

findBy can be used on the model to find an element based on custom key. If you need to find a element based on it's name value you can now use: model.findBy('name', 'Jane Doe') and you'll receive the found Entry Object.

Customize the Model with filters:

When instantiating a new Model, you can now pass in a filters object. The filters object should be a list of functions that return a subset of all available entries. The functions get the collection passed in, and up you go.
Here's an example:

const tasks = new Model({
  data: [
    {task: 'Go for a walk', done: false},
    {task: 'Buy Milk', done: true},
    {taks: 'Feed the cat', done: true}
  ],
  filters: {
    completed: (c) => c.filter(t => t.done === true)
  }
})

console.log(tasks.completed.length) //= 2

Best,
Roman