vuex-orm-decorators
Advanced tools
Comparing version 1.1.0 to 1.1.1
{ | ||
"name": "vuex-orm-decorators", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Simple Typescript decorators to improve the vuex-orm experience in Typescript by introducing typed property access.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -8,5 +8,5 @@ # vuex-orm-decorators | ||
Using the decorators allows better type safety in your projects by allowing you to create conventional Typescript properties, and anotate them as fields. Intellisense in Visual Studio Code just works with the annotations, where it doesn't in the vanilla plugin without boilerplate. Removes the 'magic string' aspect of vuex-orm. | ||
Using the decorators allows better type safety in your projects by allowing you to create conventional Typescript properties, and anotate them as fields for a better experience. Intellisense in Visual Studio Code just works with the annotations, where it doesn't in the vanilla plugin without boilerplate. | ||
This documentation isn't supposed to be a replacement for the vuex-orm documentation, if you are unfamiliar with the concepts the check out their documentation: https://vuex-orm.github.io/vuex-orm/guide/prologue/what-is-vuex-orm.html. I have linked to relevant guide pages in their documation throughout this documentation. | ||
This documentation isn't supposed to be a replacement for the vuex-orm documentation, if you are unfamiliar with the concepts of vuex-orm then check out their documentation: https://vuex-orm.github.io/vuex-orm/guide/prologue/what-is-vuex-orm.html. I have linked to relevant guide pages in their documation throughout this documentation. | ||
@@ -18,2 +18,3 @@ ##### Contribute | ||
| ||
# Setup | ||
### Installation | ||
@@ -27,3 +28,21 @@ | ||
| ||
### Auto Model Registration | ||
Models can automatically register themselves in the database. To do so, instead of installing the vuex-orm database, install the wrapper provided by this library as follows: | ||
```typescript | ||
import Vue from 'vue'; | ||
import Vuex from 'vuex'; | ||
import { ORMDatabase } from 'vuex-orm-decorators' | ||
Vue.use(Vuex); | ||
export default new Vuex.Store({ | ||
state: {}, | ||
modules: {}, | ||
plugins: [ORMDatabase.install()], | ||
}); | ||
``` | ||
When you use a model it registers itself in the database automatically if it has not already. | ||
If you do not want auto registered models, simply install the vanilla database and register them as you would normally. | ||
### Typescript | ||
@@ -36,3 +55,3 @@ | ||
| ||
# Usage | ||
### Basic Usage | ||
@@ -42,6 +61,6 @@ | ||
```typescript | ||
import { Model } from '@vuex-orm/core' | ||
import { Model } from '@vuex-orm/core'; | ||
class User extends Model { | ||
static entity = 'users' | ||
static entity = 'users'; | ||
@@ -52,3 +71,3 @@ static fields () { | ||
name: this.attr('') | ||
} | ||
}; | ||
} | ||
@@ -75,3 +94,2 @@ } | ||
| ||
### Getters | ||
@@ -82,4 +100,4 @@ | ||
```typescript | ||
import { Model } from '@vuex-orm/core' | ||
import { AttrField, StringField } from 'vuex-orm-decorators' | ||
import { Model } from '@vuex-orm/core'; | ||
import { AttrField, StringField } from 'vuex-orm-decorators'; | ||
@@ -102,3 +120,2 @@ | ||
| ||
### Setting a Primary Key | ||
@@ -109,4 +126,4 @@ | ||
```typescript | ||
import { Model } from '@vuex-orm/core' | ||
import { AttrField, StringField } from 'vuex-orm-decorators' | ||
import { Model } from '@vuex-orm/core'; | ||
import { AttrField, StringField } from 'vuex-orm-decorators'; | ||
@@ -127,3 +144,2 @@ | ||
| ||
### Generic Types | ||
@@ -133,3 +149,2 @@ | ||
| ||
### Auto Increment | ||
@@ -139,3 +154,2 @@ | ||
| ||
### Primative Types | ||
@@ -149,3 +163,2 @@ | ||
| ||
### Creating Relationships | ||
@@ -152,0 +165,0 @@ |
@@ -5,3 +5,3 @@ import VuexORM, { Model, Database } from '@vuex-orm/core'; | ||
export default class ORMDatabase { | ||
export class ORMDatabase { | ||
@@ -8,0 +8,0 @@ private static _ormDatabase: Database; |
@@ -5,2 +5,3 @@ import { Attribute, Model } from '@vuex-orm/core'; | ||
export { OrmModel } from './model'; | ||
export { ORMDatabase } from './database'; | ||
@@ -7,0 +8,0 @@ export { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33470
408
165