2.4.2 • Published 6 years ago

@events/snapshot-mongo v2.4.2

Weekly downloads
2
License
ISC
Repository
-
Last release
6 years ago

@events/snapshot-mongo

This package receives a stream of commands, converts them to mongodb commands and persists them to a mongodb database. It also takes care of optimistic locking to ensure data consistency.

API

  1. version(config: PersistenceConfig, collections: CollectionMeta[]): Promise<SnapshotVersionMeta>
const { persist, version } = require('@events/snapshot-mongo');

const persistenceConfig = {
  store: 'mongodb://localhost/my_example_db',
};

const interestedCollections = [
  { name: 'users', version: '1.0.0' },
  { name: 'users', version: '2.0.0' },
  { name: 'posts', version: '1.0.0' },
  { name: 'posts', version: '1.2.0' },
];

// get the latest snapshot version from mongodb://localhost/my_example_db
const snapshotMeta = await version(persistenceConfig, interestedCollections);

const { snapshotVersion } = snapshotMeta;

console.log(snapshotVersion) // logs: 5
  1. persists
const storeConfig = {
  _: ['mongodb://localhost/my_example_db']
}

const interestedCollections = [
  { name: 'users', version: '1.0.0' },
  { name: 'users', version: '2.0.0' },
  { name: 'posts', version: '1.0.0' },
  { name: 'posts', version: '1.2.0' },
];

// create a persistence stream from a projection stream
const persistence$ = await persist(
  storeConfig,
  projection$,
  interestedCollections
);
2.4.2

6 years ago

2.4.1

6 years ago

2.4.0

6 years ago

2.4.0-0

6 years ago

2.3.0

6 years ago

2.2.9

6 years ago

2.2.8

6 years ago

2.2.6

6 years ago

2.2.5

6 years ago

2.2.4

6 years ago

2.2.3

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.2.0-0

6 years ago

2.1.0-0

7 years ago

2.0.0-8

7 years ago

2.0.0-6

7 years ago

2.0.0-1

7 years ago

2.0.0-0

7 years ago

1.2.0-0

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago

1.0.0-beta.5

7 years ago

1.0.0-beta.4

7 years ago

1.0.0-beta.0

7 years ago

1.0.0-rc.11

7 years ago