add_readAndWritePrefix_index.js 486 B

1234567891011121314151617181920212223
  1. const mongojs = require('../../app/src/infrastructure/mongojs')
  2. const { db } = mongojs
  3. const keys = { 'tokens.readAndWritePrefix': 1 }
  4. const opts = {
  5. unique: true,
  6. partialFilterExpression: {
  7. 'tokens.readAndWritePrefix': { $exists: true }
  8. },
  9. background: true
  10. }
  11. console.log(
  12. `>> Creating index on ${JSON.stringify(keys)}, ${JSON.stringify(opts)}`
  13. )
  14. db.projects.createIndex(keys, opts, err => {
  15. if (err) {
  16. throw err
  17. }
  18. console.log('>> done')
  19. process.exit(0)
  20. })