@data-fair/lib-node 2.1.1 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/mongo.js +8 -1
  2. package/package.json +1 -1
package/mongo.js CHANGED
@@ -43,11 +43,18 @@ export class Mongo {
43
43
  */
44
44
  configure = async (indexDefinitions) => {
45
45
  for (const collectionName in indexDefinitions) {
46
+ try {
47
+ await this.db.createCollection(collectionName)
48
+ } catch (err) {
49
+ // nothing TODO
50
+ }
46
51
  for (const indexName in indexDefinitions[collectionName]) {
47
52
  let key, options
48
53
  const indexDefinition = indexDefinitions[collectionName][indexName]
49
54
  if (indexDefinition === null) {
50
- await this.db.collection(collectionName).dropIndex(indexName)
55
+ if (await this.db.collection(collectionName).indexExists(indexName)) {
56
+ await this.db.collection(collectionName).dropIndex(indexName)
57
+ }
51
58
  continue
52
59
  } else if (Array.isArray(indexDefinition)) {
53
60
  [key, options] = indexDefinition
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@data-fair/lib-node",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "Small nodejs related utility functions for the data-fair stack.",
5
5
  "main": "index.js",
6
6
  "files": [