mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #142 from sharelatex/sk-fix-token-indexes
use correct partial indexes on project token fields
This commit is contained in:
commit
10fc89c8cf
7 changed files with 45 additions and 15 deletions
|
@ -2,7 +2,10 @@ mongoose = require('mongoose')
|
|||
Settings = require 'settings-sharelatex'
|
||||
logger = require('logger-sharelatex')
|
||||
|
||||
mongoose.connect(Settings.mongo.url, server: poolSize: 10)
|
||||
mongoose.connect(Settings.mongo.url, {
|
||||
server: {poolSize: 10},
|
||||
config: {autoIndex: false}
|
||||
})
|
||||
|
||||
mongoose.connection.on 'connected', () ->
|
||||
logger.log {url:Settings.mongo.url}, 'mongoose default connection open'
|
||||
|
|
|
@ -33,8 +33,20 @@ ProjectSchema = new Schema
|
|||
imageName : { type: String }
|
||||
track_changes : { type: Object }
|
||||
tokens :
|
||||
readOnly : { type: String, index: {unique: true} }
|
||||
readAndWrite : { type: String, index: {unique: true} }
|
||||
readOnly : {
|
||||
type: String,
|
||||
index: {
|
||||
unique: true,
|
||||
partialFilterExpression: {'tokens.readOnly': {$exists: true}}
|
||||
}
|
||||
}
|
||||
readAndWrite : {
|
||||
type: String,
|
||||
index: {
|
||||
unique: true,
|
||||
partialFilterExpression: {'tokens.readAndWrite': {$exists: true}}
|
||||
}
|
||||
}
|
||||
tokenAccessReadOnly_refs : [ type:ObjectId, ref:'User' ]
|
||||
tokenAccessReadAndWrite_refs : [ type:ObjectId, ref:'User' ]
|
||||
overleaf :
|
||||
|
@ -61,12 +73,14 @@ applyToAllFilesRecursivly = ProjectSchema.statics.applyToAllFilesRecursivly = (f
|
|||
_.each folder.folders, (folder)->
|
||||
applyToAllFilesRecursivly(folder, fun)
|
||||
|
||||
|
||||
ProjectSchema.methods.getSafeProjectName = ->
|
||||
safeProjectName = this.name.replace(new RegExp("\\W", "g"), '_')
|
||||
return sanitize.escape(safeProjectName)
|
||||
|
||||
conn = mongoose.createConnection(Settings.mongo.url, server: poolSize: Settings.mongo.poolSize || 10)
|
||||
conn = mongoose.createConnection(Settings.mongo.url, {
|
||||
server: {poolSize: Settings.mongo.poolSize || 10},
|
||||
config: {autoIndex: false}
|
||||
})
|
||||
|
||||
Project = conn.model('Project', ProjectSchema)
|
||||
|
||||
|
|
|
@ -30,9 +30,10 @@ ProjectInviteSchema = new Schema(
|
|||
}
|
||||
)
|
||||
|
||||
|
||||
conn = mongoose.createConnection(Settings.mongo.url, server: poolSize: Settings.mongo.poolSize || 10)
|
||||
|
||||
conn = mongoose.createConnection(Settings.mongo.url, {
|
||||
server: {poolSize: Settings.mongo.poolSize || 10},
|
||||
config: {autoIndex: false}
|
||||
})
|
||||
|
||||
ProjectInvite = conn.model('ProjectInvite', ProjectInviteSchema)
|
||||
|
||||
|
|
|
@ -25,8 +25,10 @@ SubscriptionSchema.statics.findAndModify = (query, update, callback)->
|
|||
this.update query, update, ->
|
||||
self.findOne query, callback
|
||||
|
||||
|
||||
conn = mongoose.createConnection(Settings.mongo.url, server: poolSize: Settings.mongo.poolSize || 10)
|
||||
conn = mongoose.createConnection(Settings.mongo.url, {
|
||||
server: {poolSize: Settings.mongo.poolSize || 10},
|
||||
config: {autoIndex: false}
|
||||
})
|
||||
|
||||
Subscription = conn.model('Subscription', SubscriptionSchema)
|
||||
|
||||
|
|
|
@ -7,6 +7,10 @@ ObjectId = Schema.ObjectId
|
|||
SystemMessageSchema = new Schema
|
||||
content : type: String, default:''
|
||||
|
||||
conn = mongoose.createConnection(Settings.mongo.url, server: poolSize: Settings.mongo.poolSize || 10)
|
||||
conn = mongoose.createConnection(Settings.mongo.url, {
|
||||
server: {poolSize: Settings.mongo.poolSize || 10},
|
||||
config: {autoIndex: false}
|
||||
})
|
||||
|
||||
|
||||
exports.SystemMessage = conn.model('SystemMessage', SystemMessageSchema)
|
||||
|
|
|
@ -64,7 +64,10 @@ UserSchema = new Schema
|
|||
accessToken: { type: String }
|
||||
refreshToken: { type: String }
|
||||
|
||||
conn = mongoose.createConnection(Settings.mongo.url, server: poolSize: 10)
|
||||
conn = mongoose.createConnection(Settings.mongo.url, {
|
||||
server: {poolSize: Settings.mongo.poolSize || 10},
|
||||
config: {autoIndex: false}
|
||||
})
|
||||
|
||||
User = conn.model('User', UserSchema)
|
||||
|
||||
|
|
|
@ -9,7 +9,10 @@ UserStubSchema = new Schema
|
|||
last_name : { type : String, default : '' }
|
||||
overleaf : { id: { type: Number } }
|
||||
|
||||
conn = mongoose.createConnection(Settings.mongo.url, server: poolSize: 10)
|
||||
conn = mongoose.createConnection(Settings.mongo.url, {
|
||||
server: {poolSize: Settings.mongo.poolSize || 10},
|
||||
config: {autoIndex: false}
|
||||
})
|
||||
|
||||
UserStub = conn.model('UserStub', UserStubSchema)
|
||||
|
||||
|
|
Loading…
Reference in a new issue