UNPKG

@unchainedshop/core-events

Version:

This package defines the event module which ensures the emitted events are written to the database as an Event History and offers a core module to search for events.

25 lines 847 B
import { isDocumentDBCompatModeEnabled } from '@unchainedshop/mongodb'; import { buildDbIndexes } from '@unchainedshop/mongodb'; const TWO_DAYS_SEC = 172800; export const EventsCollection = async (db) => { const Events = db.collection('events'); await buildDbIndexes(Events, [ { index: { created: -1 }, options: { expireAfterSeconds: TWO_DAYS_SEC, name: 'created' }, }, { index: { type: 1 }, options: { name: 'type' } }, !isDocumentDBCompatModeEnabled() && { index: { _id: 'text', type: 'text' }, options: { weights: { _id: 8, type: 4, }, name: 'events_fulltext_search', }, }, ]); return Events; }; //# sourceMappingURL=EventsCollection.js.map