add_readAndWritePrefix_index.js 462 B

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