mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-06 03:50:26 +02:00
New directory organization
This commit is contained in:
parent
86435b9bae
commit
cda021079f
40 changed files with 40 additions and 41 deletions
61
initializers/database.js
Normal file
61
initializers/database.js
Normal file
|
@ -0,0 +1,61 @@
|
|||
;(function () {
|
||||
'use strict'
|
||||
|
||||
var config = require('config')
|
||||
var mongoose = require('mongoose')
|
||||
|
||||
var constants = require('./constants')
|
||||
var logger = require('../helpers/logger')
|
||||
|
||||
var dbname = 'peertube' + config.get('database.suffix')
|
||||
var host = config.get('database.host')
|
||||
var port = config.get('database.port')
|
||||
|
||||
// ----------- Videos -----------
|
||||
var videosSchema = mongoose.Schema({
|
||||
name: String,
|
||||
namePath: String,
|
||||
description: String,
|
||||
magnetUri: String,
|
||||
podUrl: String
|
||||
})
|
||||
|
||||
var VideosDB = mongoose.model('videos', videosSchema)
|
||||
|
||||
// ----------- Pods -----------
|
||||
var podsSchema = mongoose.Schema({
|
||||
url: String,
|
||||
publicKey: String,
|
||||
score: { type: Number, max: constants.FRIEND_BASE_SCORE }
|
||||
})
|
||||
|
||||
var PodsDB = mongoose.model('pods', podsSchema)
|
||||
|
||||
// ----------- PoolRequests -----------
|
||||
var poolRequestsSchema = mongoose.Schema({
|
||||
type: String,
|
||||
id: String, // Special id to find duplicates (video created we want to remove...)
|
||||
request: mongoose.Schema.Types.Mixed
|
||||
})
|
||||
|
||||
var PoolRequestsDB = mongoose.model('poolRequests', poolRequestsSchema)
|
||||
|
||||
// ----------- Connection -----------
|
||||
|
||||
mongoose.connect('mongodb://' + host + ':' + port + '/' + dbname)
|
||||
mongoose.connection.on('error', function () {
|
||||
logger.error('Mongodb connection error.')
|
||||
process.exit(0)
|
||||
})
|
||||
|
||||
mongoose.connection.on('open', function () {
|
||||
logger.info('Connected to mongodb.')
|
||||
})
|
||||
|
||||
// ----------- Export -----------
|
||||
module.exports = {
|
||||
VideosDB: VideosDB,
|
||||
PodsDB: PodsDB,
|
||||
PoolRequestsDB: PoolRequestsDB
|
||||
}
|
||||
})()
|
Loading…
Add table
Add a link
Reference in a new issue