Skip to content

Releases: vuex-orm/vuex-orm

v0.31.10

23 Apr 14:04
Compare
Choose a tag to compare

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

16 Apr 12:32
Compare
Choose a tag to compare

Improvements

  • #337 You can now pass an array to the with method.

Thanks @tvillaren for this wonderful PR! 🎉

v0.31.8

08 Apr 13:20
Compare
Choose a tag to compare

Fixes

  • #317 Fixed where it was not working on IE11 because usage of Object.assign is not polyfilled properly.

Thanks to @dtkahl for the report and thanks @kkyouhei for the fix 🎉

v0.31.7

26 Mar 14:48
Compare
Choose a tag to compare

Fixes

  • #294 Fixed when updating belongs to many relations not populating correct field at pivot entity.
  • #318 Fixed typo in error message.

Thanks to @kkyouhei and @bertBruynooghe for the awesome PR! 🎉

v0.31.6

25 Feb 13:32
Compare
Choose a tag to compare

Fixes

  • Fix where "many" type relation returning undefined instead of null when there's nothing to reference.
  • #299 Fix where hasMany was ignoring localKey argument.

Thanks to @kkyouhei as always for the lovely fix! 🎉

v0.31.5

19 Feb 12:14
Compare
Choose a tag to compare

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 returning undefined 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

12 Feb 14:24
Compare
Choose a tag to compare

Fixes

  • #258 Fixes where morphToMany relation duplicates the pivot records when used with increment field type.
  • Bring back IE11 support by adding Object.values polifyll.

Thanks @kkyouhei for the wonderful PR! 🎉

v0.31.3

03 Feb 05:55
Compare
Choose a tag to compare

Improvements

Update state key when a user updates the primary key for the record.

Issue: #90

When trying to update the primary key, for example, id for the record, now it will update the state key as well.

Fixes

  • #255 Fix non-POJP warning when using Vuex ORM with Nuxt SSR.

v0.31.2

25 Dec 14:02
Compare
Choose a tag to compare

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

04 Dec 22:40
Compare
Choose a tag to compare

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! 🎉