knexentity

0.0.7 • Public • Published

Knex Entity

[Typescript only]Simple schema Context/Entity builder

How to use ?

> npm install knexentity
> mkdir models
> npx knextable toModel <your_schema> --useMoment --genContext --toFolder ./models
import knex from 'knex';
import { forumContext } from './models/forumContext';
import { usersEntity } from './models/users';
import { topicsEntity } from './models/topics';

const dbForum = new forumContext(knex({ ... your knex config ... }));

async function getAllTopicByUser(currentUser: userEntity) : topicEntity[] {
  return dbForum.topics.fromDb((query, table) => {
    query.where(table.Column.userId, currentUser.id);
  });
}

Readme

Keywords

none

Package Sidebar

Install

npm i knexentity

Weekly Downloads

2

Version

0.0.7

License

MIT

Unpacked Size

13.2 kB

Total Files

12

Last publish

Collaborators

  • deliay