Django Tastypie models for Bookshelf
npm install bookshelf-tastypie --save
yarn add bookshelf-tastypie
Load models to registry
require('bookshelf-tastypie')(bookshelf);
or load model/collection
let ApiKey = require('bookshelf-tastypie')(bookshelf).ApiKey;
ApiKey model
String representation of api key
Static function to generate unique keys
ApiKey = bookshelf.model('Tastypie.ApiKey')
new_key = ApiKey.generateKey()
ApiKey collection
String representation od api access
In beforeAll
hook runs knex migrations in order
- Django
- Tastypie
- Your project
All migrations must have own migration table (tableName
property).
before(function() {
knex.migrate.latest({directory: 'node_modules/bookshelf-django/migrations/', tableName: 'knex_migrations_django'})
}).then(function() {
knex.migrate.latest({directory: 'node_modules/bookshelf-tastypie/migrations/', tableName: 'knex_migrations_tastypie'})
}).then(function() {
knex.migrate.latest({directory: 'src/migrations/', tableName: 'knex_migrations_my_project'})
})
In afterAll
hook runs knex migrations in reverse order
- Your project
- Tastypie
- Django
after(function() {
knex.migrate.rollback({directory: 'src/migrations/', tableName: 'knex_migrations_my_project'})
}).then(function() {
knex.migrate.rollback({directory: 'node_modules/bookshelf-tastypie/migrations/', tableName: 'knex_migrations_tastypie'})
}).then(function() {
knex.migrate.rollback({directory: 'node_modules/bookshelf-django/migrations/', tableName: 'knex_migrations_django'})
})