mongo2elastic
Version:
Sync MongoDB collections to Elasticsearch
20 lines (16 loc) • 546 B
text/typescript
import type { Collection } from 'mongodb'
export const indexFromCollection = (collection: Collection) =>
collection.collectionName.toLowerCase()
export const indexFromDbAndCollection = (collection: Collection) =>
`${collection.dbName.toLowerCase()}_${collection.collectionName.toLowerCase()}`
/**
* Does arr start with startsWith array.
*/
export const arrayStartsWith = (arr: any[], startsWith: any[]) => {
for (let i = 0; i < startsWith.length; i++) {
if (arr[i] !== startsWith[i]) {
return false
}
}
return true
}