@mergehez/ormvan-adonisjs
v0.1.0
Published
AdonisJS integration for @mergehez/ormvan: the ACE orm:migrate command, the database session store, and the VineJS exists/unique rules.
Maintainers
Readme
@mergehez/ormvan-adonisjs
The AdonisJS adapter for @mergehez/ormvan. It re-exports the whole engine,
so an AdonisJS app imports this package and never @mergehez/ormvan directly, and it adds the few pieces that speak
AdonisJS' contracts.
Install
npm install @mergehez/ormvan-adonisjsThis pulls in @mergehez/ormvan for you. @adonisjs/session and @vinejs/vine are optional peers: install them only when
you use the store or the rules.
What it adds
@mergehez/ormvan-adonisjs— the engine's public surface, re-exported, with the engine's request context narrowed to AdonisJS'HttpContext. Importing this module is what makessave(ctx)andgetAuthUser(ctx)speakHttpContext.@mergehez/ormvan-adonisjs/orm_session— thedatabasesession store.@mergehez/ormvan-adonisjs/orm_vine— the VineJSexistsanduniquerules.@mergehez/ormvan-adonisjs/commands/orm_migrate— the ACEorm:migratecommand.
Use
// <app>/app/orm/project_orm.ts
import { Orm, PlainBaseModel } from '@mergehez/ormvan-adonisjs';
Orm.configure({
getExecutor: (connectionName) => connections.executor(connectionName),
now: () => dt.unix(),
getAuthUser: (ctx) => authUser(ctx), // `ctx` is AdonisJS' HttpContext
});
export { Orm };
export class ModelBase extends PlainBaseModel {}Declare the migrate command in adonisrc.ts:
// adonisrc.ts
export default defineConfig({
commands: [
() => import('@adonisjs/core/commands'),
() => import('@mergehez/ormvan-adonisjs/commands/orm_migrate'),
],
});Documentation
License
MIT
