0.3.6 • Published 6 years ago

bookshelf-schema v0.3.6

Weekly downloads
214
License
MIT
Repository
github
Last release
6 years ago

bookshelf-schema

Documentation

The Bookshelf plugin that adds fields, relations, scopes and more to bookshelf models.

Like a bookshelf-fields but better.

Documentation on readthedocs.org

Usage

class User extends db.Model
    tableName: 'users'
    @schema [
        EmailField 'email'
        EncryptedStringField 'password'
        BooleanField 'active'
        HasMany 'Photo'
        Scope 'isActive', -> @where active: true
    ]

or

User = db.Model.extend({ tableName: 'users'}, {
    schema: [
        EmailField('email'),
        EncryptedStringField('password'),
        BooleanField('active'),
        HasMany('Photo'),
        Scope('isActive', function(){ return this.where({active: true}); })
    ]
});

Installation

npm install bookshelf-schema

And then

bookshelf.plugin require('bookshelf-schema')()

Contributing

  • If you've found a bug or missed some feature - your are welcome to post an issue
  • PRs are appreciated. But try to stay focused, if feature can be implemented as a separate project, keep it separately
  • PRs to documentation a very appreciated too. English isn't my native language so I feel quite bad about documentation quality. Don't hesitate to spellcheck, reformulate or even rewrite parts of it completely
0.3.6

6 years ago

0.3.5

7 years ago

0.3.4

7 years ago

0.3.3

7 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.5

8 years ago

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago