Inception
So far 0.7.0 marks the most important release of Modelist so far.
Why? I was able to add my first user-requested feature #1 to add model.validate
support to be called from outside. Also, I tackled some shortcomings that arose from working with Modelist in production with my colleagues. Those important additions are added now as well. I basically had to rework the instance structure and how it all comes together to support the upgrade filters
.
Details:
- validate() method - A validate method can now be called and will validate against the passed in schema.
- last() - A handy companion to the
first()
method, and will give you the last element of the collection. - has(key) - You can now check if an element exists in the collection using
has
and passing in the primaryKey. Works likefind
but will return aBoolean
Drumroll please 🥁
- filters - Filters passed in to the instance will no longer just return the filtered array, but a new
Model
instance giving you access to everything the core of Modelist supports.
Here is a short example:
const model = new Model({
data: [
{ id: 1, task: 'Buy Milk', done: false },
{ id: 2, task: 'Update Modelist', done: true },
],
filters: {
completed: c => c.filter(e => e.done)
}
})
model.completed.size // = 1
model.completed.all() // [{ id: 2, task: 'Update Modelist', done: true }]
model.completed.first() // [{ id: 2, task: 'Update Modelist', done: true }]
// ... and all the other stuff you love