overleaf/services/web/scripts/project-tokens/add_readAndWritePrefix_index.js

24 lines
486 B
JavaScript
Raw Normal View History

const mongojs = require('../../app/src/infrastructure/mongojs')
const { db } = 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)
})