2.4.2 • Published 7 years ago

@events/snapshot-mongo v2.4.2

Weekly downloads
2
License
ISC
Repository
-
Last release
7 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

7 years ago

2.4.1

7 years ago

2.4.0

7 years ago

2.4.0-0

7 years ago

2.3.0

8 years ago

2.2.9

8 years ago

2.2.8

8 years ago

2.2.6

8 years ago

2.2.5

8 years ago

2.2.4

8 years ago

2.2.3

8 years ago

2.2.1

8 years ago

2.2.0

8 years ago

2.2.0-0

8 years ago

2.1.0-0

8 years ago

2.0.0-8

8 years ago

2.0.0-6

8 years ago

2.0.0-1

8 years ago

2.0.0-0

8 years ago

1.2.0-0

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago

1.0.0-beta.5

8 years ago

1.0.0-beta.4

8 years ago

1.0.0-beta.0

8 years ago

1.0.0-rc.11

8 years ago