Package Exports
- objectionjs-repository
- objectionjs-repository/build/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (objectionjs-repository) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
ObjectionJS Repository
ObjectionJS Repository is repository pattern implementation on top of KnexJS and ObjectionJS
Installation
$ npm i objectionjs-repositoryUsage
// Define Interface
export interface IUser {
id: number;
age: number;
name: string;
}
// Define Model
export default class User extends Model {
static get tableName() {
return TABLES.USER;
}
}
// Define Repository
import { BaseRepository } from 'objectionjs-repository';
export class UserRepository extends BaseRepository<IUser> {
constructor(knexInstance: Knex) {
super(User, knexInstance);
}
}
then you can use defined repository
const userRepo = new UserRepository(knexInstance);
const user = await userRepo.getOne({ age: 25 })API
getOne(conditions, [options])
getAll(conditions, [options])
create(data, [options])
createMany(data, [options])
update(conditions, data, [options])
delete(conditions, [options])
Support
Feel free to open issues on github.