Skip to content

smnscp/vuex-orm-plugin-date-attribute

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vuex ORM Plugin: Date Attribute

JavaScript Style Guide License

⚠️ State of This Package

I wrote this little Vuex ORM plugin in 2019 for a project I was working on back then.

Meanwhile, the packaging setup got reeeally dated. 😬 I won’t have the time to maintain it until I start my next Vue project. So, I decided to remove all the outdated dependencies (devDependencies section, dist files, package-lock.json).

The actual code (/src/*) should™ still work (it’s not rocket science, anyways). But one would have to integrate it in a working bundling environment.

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),
    };
  }
}

About

Vuex-ORM Plugin to enable date type attributes.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published