Skip to content

A Sequelize implementation for Flexible Persistence's PersistenceAdapter

License

Notifications You must be signed in to change notification settings

Judahh/sequelizePersistence

Repository files navigation

sequelizePersistence

Publish npm version npm downloads

A Sequelize implementation for Flexible Persistence's PersistenceAdapter

// Init Journaly as a observer platform for using as a message broker
const journaly = Journaly.newJournaly() as SubjectObserver<any>;

// config read database
read = new DAODB(database, {
  test: new TestDAO(),
  object: new ObjectDAO(),
});

// config write database
write = new MongoDB(
  new PersistenceInfo(
    {
      database: 'write',
      host: process.env.MONGO_HOST || 'localhost',
      port: process.env.MONGO_PORT,
    },
    journaly
  )
);

// init Flexible Persistence handler with write and read databases
const handler = new Handler(write, read);

// sample object
const obj = {};
obj['test'] = 'test';

// create an event to create an object
const persistencePromise = await handler.addEvent(
  new Event({ operation: Operation.create, name: 'object', content: obj })
);

// prints create event
console.log(persistencePromise);

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js.

If this is a brand new project, make sure to create a package.json first with the npm init command or yarn init command.

Installation is done using the npm install command or yarn add command:

$ npm install @flexiblepersistence/sequelize

or

$ yarn add @flexiblepersistence/sequelize

Tests

To run the test suite, first install Docker and dependencies, then run docker-compose up -d and npm test:

$ docker-compose up -d
$ npm install
$ npm test

or

$ docker-compose up -d
$ yarn
$ yarn test

People

The original author of Journaly is Judah Lima

List of all contributors

About

A Sequelize implementation for Flexible Persistence's PersistenceAdapter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published