overleaf/services/web/scripts/project-tokens/add_readAndWritePrefix_index.js
Jakob Ackermann 018a44eeb5 Merge pull request #3185 from overleaf/jpa-normalize-mongo-imports
[misc] normalize mongo imports

GitOrigin-RevId: ac653d9982e0d36736b90f4c03d4c00be88ea76a
2020-09-25 02:04:20 +00:00

22 lines
462 B
JavaScript

const { db } = require('../../app/src/infrastructure/mongojs')
const keys = { 'tokens.readAndWritePrefix': 1 }
const opts = {
unique: true,
partialFilterExpression: {
'tokens.readAndWritePrefix': { $exists: true }
},
background: true
}
console.log(
`>> Creating index on ${JSON.stringify(keys)}, ${JSON.stringify(opts)}`
)
db.projects.createIndex(keys, opts, err => {
if (err) {
throw err
}
console.log('>> done')
process.exit(0)
})