Added auto incrementing ticket number
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import mongoose from 'mongoose'
|
||||
import mongodb from 'mongodb'
|
||||
import Grid from 'gridfs-stream'
|
||||
import merge from 'mongoose-merge-plugin'
|
||||
import autobind from 'autobind-decorator'
|
||||
import * as Schemas from './schemas'
|
||||
import util from 'util'
|
||||
import mongoose from "mongoose"
|
||||
import mongodb from "mongodb"
|
||||
import Grid from "gridfs-stream"
|
||||
import merge from "mongoose-merge-plugin"
|
||||
import autobind from "autobind-decorator"
|
||||
import * as Schemas from "./schemas"
|
||||
import util from "util"
|
||||
|
||||
Grid.mongo = mongoose.mongo
|
||||
|
||||
@@ -16,20 +16,26 @@ export class DB {
|
||||
}
|
||||
|
||||
connect(mongoUri, isProduction) {
|
||||
return mongoose.connect(mongoUri, { useMongoClient: true, config: { autoIndex: !isProduction } }).then((connection) => {
|
||||
this.connection = connection
|
||||
return mongoose
|
||||
.connect(mongoUri, {
|
||||
useMongoClient: true,
|
||||
config: { autoIndex: !isProduction },
|
||||
})
|
||||
.then((connection) => {
|
||||
this.connection = connection
|
||||
|
||||
this.gridfs = Grid(connection.db)
|
||||
this.gridfs.findOneAsync = util.promisify(this.gridfs.findOne)
|
||||
this.gridfs.removeAsync = util.promisify(this.gridfs.remove)
|
||||
this.gridfs = Grid(connection.db)
|
||||
this.gridfs.findOneAsync = util.promisify(this.gridfs.findOne)
|
||||
this.gridfs.removeAsync = util.promisify(this.gridfs.remove)
|
||||
|
||||
this.User = connection.model('User', Schemas.userSchema)
|
||||
this.WorkItem = connection.model('WorkItem', Schemas.workItemSchema)
|
||||
this.Activity = connection.model('Activity', Schemas.activitySchema)
|
||||
this.Team = connection.model('Team', Schemas.teamSchema)
|
||||
this.User = connection.model("User", Schemas.userSchema)
|
||||
this.WorkItem = connection.model("WorkItem", Schemas.workItemSchema)
|
||||
this.Activity = connection.model("Activity", Schemas.activitySchema)
|
||||
this.Team = connection.model("Team", Schemas.teamSchema)
|
||||
this.Counter = connection.model("Counter", Schemas.counterSchema)
|
||||
|
||||
return Promise.resolve(this)
|
||||
})
|
||||
return Promise.resolve(this)
|
||||
})
|
||||
}
|
||||
|
||||
newObjectId(s) {
|
||||
@@ -38,14 +44,16 @@ export class DB {
|
||||
}
|
||||
|
||||
lookupToken(token, done) {
|
||||
this.User.findOne({ 'loginToken': token }).then((user) => {
|
||||
if (!user) {
|
||||
done(null, false)
|
||||
} else {
|
||||
done(null, user)
|
||||
}
|
||||
}).catch((err) => {
|
||||
done(err)
|
||||
})
|
||||
this.User.findOne({ loginToken: token })
|
||||
.then((user) => {
|
||||
if (!user) {
|
||||
done(null, false)
|
||||
} else {
|
||||
done(null, user)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
done(err)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user