@aloxide/model-sequelize
v0.6.0
Published
A model builder for Sequelize
Downloads
7
Readme
Table of content
Package @aloxide/model-sequelize
A model builder for Sequelize
Usage
import { ModelBuilder } from '@aloxide/model-sequelize';
// create model builder from an Aloxide configuration
const modelBuilder = new ModelBuilder({
aloxideConfig,
logger: Logger.createLogger({
level: 'debug',
name: 'models',
}),
});
// using mapField
import { indexStateSchema } from '@aloxide/demux';
const typeInterpreter = new SequelizeTypeInterpreter();
const indexStateSequelizeFields = ModelBuilder.mapField(
typeInterpreter,
indexStateSchema.fields,
indexStateSchema.key,
);
// use the model builder
import { Sequelize } from 'sequelize';
const sequelize = new Sequelize('sqlite::memory:');
const models = modelBuilder.build(sequelize);
models.push(sequelize.define(name, indexStateSequelizeFields));