Releases: vuex-orm/vuex-orm
v0.31.10
Improvements
-
#341 Now you can add closure as the first argument for the
attr
attribute.class User extends Model { static fields () { return { id: this.attr(null), name: this.attr('John Doe'), rand: this.attr(() => Math.random()) } } }
Fixes
- #320 Fix where some times inserting model with composite keys generating wrong value.
- #332 Fix Vuex ORM was not working on IE11 because of lack of
ownKeys
support.
Thanks to @tvillaren, @kkyouhei and @SebastianSmolorz for the awesome PR! 🔥
v0.31.9
v0.31.8
v0.31.7
v0.31.6
v0.31.5
Improvements
Introducing beforeRelations
& afterRelations
hooks.
PR: #293
Now you can use beforeRelations
& afterRelations
as a select hook.
Thanks @killix for this wonderful PR! 🎉
Fixes
- #282 Fix where
belongsToMany
relation is returningundefined
instead of empty array when there're no reference records. - #290 Fix
withAllRecursive()
retrieving empty relations and sub relations when key is null.
Thanks so much to @kkyouhei and @rkolpakov for the fixes! 🤝
v0.31.4
v0.31.3
v0.31.2
Improvements
Better TypeScript support
Previously user defined models were not protected/checked by TypeScript. Now it does! For the TS users, you can now define your models as below to get types for your model properties.
class Person extends Model {
static entity = 'persons'
static fields (): Fields {
return {
id: this.number(0),
name: this.string(''),
note: this.string('').nullable(),
options: this.hasMany(Option, 'personId')
}
}
id!: number
name!: string
note?: string
options!: Option[]
}
Exports Fields Interface for TypeScript
TypeScript requires for some models (but not all) static fields method has Fields as return type. Now you can use it by importing it from @vuex-orm/core
.
import { Fields, Model } from "@vuex-orm/core";
export default class OptionGroup extends Model {
static fields(): Fields { ... }
}
Fixes findIn
Return Value
Now it doesn't allow findIn
result array to have undefined
or null
. Correct its TypeScript return type as well.
// For data { 1: { id: 1 }, 2: { id: 2 } }
findIn([1, 3]); // It was returning [{ id: 1 }, undefined] before, now [{ id: 1}].
Thanks @ozum so much for this wonderful PR 🎉
v0.31.1
Improvements
Direct index key look support for where
clause
PR: #262
Now where
clause is going to look up the record directly by the key of the store state instead of full scanning the records if the specified field is the primary key
User.query().where('id', 1).get() // Uses id key lookup
User.query().where('other', 'abc').get() // Uses full scan as previous.
User.query().whereIdIn('id', [1, 2]).get() // Uses id key lookup
Id intersection for whereId
and whereIdIn
PR: #262
Previously when whereId
and whereIdIn
called more than once, they return the union of ids instead of an intersection of ids. This was not compliant and intuitive with the rest of the library.
Option.where("id", [1, 2]).where("id", [3, 4)]; // Returns []
Option.whereIdIn([1, 2]).whereIdIn([3, 4)]; // Previously was returning [1, 2, 3, 4], now []
Thanks so much to @ozum for this beautiful PR! 🎉