aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/database.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-01-30 17:05:22 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-01-30 17:05:22 +0100
commitcda021079ff455cc0fd0eb95a5395fa808ab63d1 (patch)
tree056716de7460462b74b861051a5e9da6e2633fce /src/database.js
parent86435b9baedfe300a28ea4545511c1b50d4119f6 (diff)
downloadPeerTube-cda021079ff455cc0fd0eb95a5395fa808ab63d1.tar.gz
PeerTube-cda021079ff455cc0fd0eb95a5395fa808ab63d1.tar.zst
PeerTube-cda021079ff455cc0fd0eb95a5395fa808ab63d1.zip
New directory organization
Diffstat (limited to 'src/database.js')
-rw-r--r--src/database.js61
1 files changed, 0 insertions, 61 deletions
diff --git a/src/database.js b/src/database.js
deleted file mode 100644
index e03176b31..000000000
--- a/src/database.js
+++ /dev/null
@@ -1,61 +0,0 @@
1;(function () {
2 'use strict'
3
4 var config = require('config')
5 var mongoose = require('mongoose')
6
7 var constants = require('./constants')
8 var logger = require('./logger')
9
10 var dbname = 'peertube' + config.get('database.suffix')
11 var host = config.get('database.host')
12 var port = config.get('database.port')
13
14 // ----------- Videos -----------
15 var videosSchema = mongoose.Schema({
16 name: String,
17 namePath: String,
18 description: String,
19 magnetUri: String,
20 podUrl: String
21 })
22
23 var VideosDB = mongoose.model('videos', videosSchema)
24
25 // ----------- Pods -----------
26 var podsSchema = mongoose.Schema({
27 url: String,
28 publicKey: String,
29 score: { type: Number, max: constants.FRIEND_BASE_SCORE }
30 })
31
32 var PodsDB = mongoose.model('pods', podsSchema)
33
34 // ----------- PoolRequests -----------
35 var poolRequestsSchema = mongoose.Schema({
36 type: String,
37 id: String, // Special id to find duplicates (video created we want to remove...)
38 request: mongoose.Schema.Types.Mixed
39 })
40
41 var PoolRequestsDB = mongoose.model('poolRequests', poolRequestsSchema)
42
43 // ----------- Connection -----------
44
45 mongoose.connect('mongodb://' + host + ':' + port + '/' + dbname)
46 mongoose.connection.on('error', function () {
47 logger.error('Mongodb connection error.')
48 process.exit(0)
49 })
50
51 mongoose.connection.on('open', function () {
52 logger.info('Connected to mongodb.')
53 })
54
55 // ----------- Export -----------
56 module.exports = {
57 VideosDB: VideosDB,
58 PodsDB: PodsDB,
59 PoolRequestsDB: PoolRequestsDB
60 }
61})()