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'
|
Settings = require 'settings-sharelatex'
|
||||||
logger = require('logger-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', () ->
|
mongoose.connection.on 'connected', () ->
|
||||||
logger.log {url:Settings.mongo.url}, 'mongoose default connection open'
|
logger.log {url:Settings.mongo.url}, 'mongoose default connection open'
|
||||||
|
|
|
@ -33,8 +33,20 @@ ProjectSchema = new Schema
|
||||||
imageName : { type: String }
|
imageName : { type: String }
|
||||||
track_changes : { type: Object }
|
track_changes : { type: Object }
|
||||||
tokens :
|
tokens :
|
||||||
readOnly : { type: String, index: {unique: true} }
|
readOnly : {
|
||||||
readAndWrite : { type: String, index: {unique: true} }
|
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' ]
|
tokenAccessReadOnly_refs : [ type:ObjectId, ref:'User' ]
|
||||||
tokenAccessReadAndWrite_refs : [ type:ObjectId, ref:'User' ]
|
tokenAccessReadAndWrite_refs : [ type:ObjectId, ref:'User' ]
|
||||||
overleaf :
|
overleaf :
|
||||||
|
@ -61,12 +73,14 @@ applyToAllFilesRecursivly = ProjectSchema.statics.applyToAllFilesRecursivly = (f
|
||||||
_.each folder.folders, (folder)->
|
_.each folder.folders, (folder)->
|
||||||
applyToAllFilesRecursivly(folder, fun)
|
applyToAllFilesRecursivly(folder, fun)
|
||||||
|
|
||||||
|
|
||||||
ProjectSchema.methods.getSafeProjectName = ->
|
ProjectSchema.methods.getSafeProjectName = ->
|
||||||
safeProjectName = this.name.replace(new RegExp("\\W", "g"), '_')
|
safeProjectName = this.name.replace(new RegExp("\\W", "g"), '_')
|
||||||
return sanitize.escape(safeProjectName)
|
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)
|
Project = conn.model('Project', ProjectSchema)
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,10 @@ ProjectInviteSchema = new Schema(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
conn = mongoose.createConnection(Settings.mongo.url, {
|
||||||
conn = mongoose.createConnection(Settings.mongo.url, server: poolSize: Settings.mongo.poolSize || 10)
|
server: {poolSize: Settings.mongo.poolSize || 10},
|
||||||
|
config: {autoIndex: false}
|
||||||
|
})
|
||||||
|
|
||||||
ProjectInvite = conn.model('ProjectInvite', ProjectInviteSchema)
|
ProjectInvite = conn.model('ProjectInvite', ProjectInviteSchema)
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,10 @@ SubscriptionSchema.statics.findAndModify = (query, update, callback)->
|
||||||
this.update query, update, ->
|
this.update query, update, ->
|
||||||
self.findOne query, callback
|
self.findOne query, callback
|
||||||
|
|
||||||
|
conn = mongoose.createConnection(Settings.mongo.url, {
|
||||||
conn = mongoose.createConnection(Settings.mongo.url, server: poolSize: Settings.mongo.poolSize || 10)
|
server: {poolSize: Settings.mongo.poolSize || 10},
|
||||||
|
config: {autoIndex: false}
|
||||||
|
})
|
||||||
|
|
||||||
Subscription = conn.model('Subscription', SubscriptionSchema)
|
Subscription = conn.model('Subscription', SubscriptionSchema)
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,10 @@ ObjectId = Schema.ObjectId
|
||||||
SystemMessageSchema = new Schema
|
SystemMessageSchema = new Schema
|
||||||
content : type: String, default:''
|
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)
|
exports.SystemMessage = conn.model('SystemMessage', SystemMessageSchema)
|
||||||
|
|
|
@ -64,7 +64,10 @@ UserSchema = new Schema
|
||||||
accessToken: { type: String }
|
accessToken: { type: String }
|
||||||
refreshToken: { 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)
|
User = conn.model('User', UserSchema)
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,10 @@ UserStubSchema = new Schema
|
||||||
last_name : { type : String, default : '' }
|
last_name : { type : String, default : '' }
|
||||||
overleaf : { id: { type: Number } }
|
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)
|
UserStub = conn.model('UserStub', UserStubSchema)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue