]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/models/application.js
Server: do not forget to check the signature when another pod wants to
[github/Chocobozzz/PeerTube.git] / server / models / application.js
CommitLineData
00d6b0dd
C
1const mongoose = require('mongoose')
2
3// ---------------------------------------------------------------------------
4
5const ApplicationSchema = mongoose.Schema({
6 mongoSchemaVersion: {
7 type: Number,
8 default: 0
9 }
10})
11
12ApplicationSchema.statics = {
13 loadMongoSchemaVersion: loadMongoSchemaVersion,
14 updateMongoSchemaVersion: updateMongoSchemaVersion
15}
16
17mongoose.model('Application', ApplicationSchema)
18
19// ---------------------------------------------------------------------------
20
21function loadMongoSchemaVersion (callback) {
22 return this.findOne({}, { mongoSchemaVersion: 1 }, function (err, data) {
23 const version = data ? data.mongoSchemaVersion : 0
24
25 return callback(err, version)
26 })
27}
28
29function updateMongoSchemaVersion (newVersion, callback) {
30 return this.update({}, { mongoSchemaVersion: newVersion }, callback)
31}