0.1.1 • Published 5 years ago

vuex-orm-plugin-date-attribute v0.1.1

Weekly downloads
52
License
MIT
Repository
-
Last release
5 years ago

Vuex ORM Plugin: Date Attribute

JavaScript Style Guide License

Installation

import VuexORM from '@vuex-orm/core'
import datePlugin from 'vuex-orm-plugin-date-attribute'

VuexORM.use(datePlugin)

Usage in Model Definition

// models/User.js
import { Model } from '@vuex-orm/core'

export default class User extends Model {
  static entity = 'users'

  static fields () {
    return {
      id: this.increment(),
      name: this.string(''),
      active: this.boolean(false),
      // Use plugged-in attribute creator Model.date() to create a field whose value will be a Date object.
      last_login: this.date(null),
      login_count: this.number(0),
    }
  }
}