3.2.15 • Published 5 years ago
@js-entity-repos/knex v3.2.15
knex
A concrete implementation of js-entity-repos for knex.
Usage
- Install it with
npm i @js-entity-repos/knex
. - For each entity you will need to do the following.
Entity Interface
import Entity from '@js-entity-repos/core/dist/types/Entity';
export interface TodoEntity extends Entity {
readonly description: string;
readonly completed: boolean;
}
Construct the Facade
import factory from '@js-entity-repos/knex/dist/factory';
import connectToDb from '@js-entity-repos/knex/dist/utils/connectToDb';
const todosFacade = factory<TodoEntity>({
// Optional property to convert an entity to a DB document. Defaults to the function below.
constructDocument: (patch) => {
return patch;
},
// Optional property to convert a DB document to an entity. Defaults to the function below.
constructEntity: (document) => {
return document;
},
// Optional property to convert an entity filter to a DB filter. Defaults to the function below.
constructFilter: (filter) => {
return filter;
},
// Optional property to construct an initial database query. Defaults to the function below.
constructQuery: (db) => {
return db.table('todos');
},
// Optional property to convert an entity sort to a DB sort. Defaults to the function below.
constructSort: (sort) => {
return sort;
},
db: connectToDb({
client: 'mysql',
connection: {
database: 'todoapp',
host: '127.0.0.1',
password: 'pword',
user: 'todouser',
},
}),
// Optional property. Defaults to 10.
defaultPaginationLimit: 10,
entityName: 'todo',
// Optional property. Defaults to the entityName.
tableName: 'todos',
});
3.2.15
5 years ago
3.2.14
5 years ago
3.2.13
5 years ago
3.2.12
5 years ago
3.2.11
5 years ago
3.2.10
5 years ago
3.2.9
6 years ago
3.2.8
6 years ago
3.2.7
6 years ago
3.2.6
6 years ago
3.2.5
6 years ago
3.2.4
6 years ago
3.2.3
6 years ago
3.2.2
6 years ago
3.2.1
6 years ago
3.2.0
6 years ago
3.1.0
6 years ago
3.0.3
6 years ago
3.0.2
6 years ago
3.0.1
6 years ago
3.0.0
6 years ago
2.0.3
6 years ago
2.0.2
6 years ago
2.0.1
6 years ago
2.0.0
6 years ago
1.0.0
6 years ago