mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-05-09 02:37:11 +02:00
feat(torrent): add table 'complete' to save user download complete torrents and count up/down ratio
This commit is contained in:
54
modules/torrents/server/models/complete.server.model.js
Normal file
54
modules/torrents/server/models/complete.server.model.js
Normal file
@@ -0,0 +1,54 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
var mongoose = require('mongoose'),
|
||||
Schema = mongoose.Schema;
|
||||
|
||||
/**
|
||||
* Complete Schema
|
||||
*/
|
||||
var CompleteSchema = new Schema({
|
||||
user: {
|
||||
type: Schema.Types.ObjectId,
|
||||
ref: 'User'
|
||||
},
|
||||
torrent: {
|
||||
type: Schema.Types.ObjectId,
|
||||
ref: 'Torrent'
|
||||
},
|
||||
total_uploaded: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
total_downloaded: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
total_ratio: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
total_seed_time: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
total_seed_day: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
hnr_warning: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
createdAt: {
|
||||
type: Date,
|
||||
default: Date.now
|
||||
}
|
||||
});
|
||||
|
||||
CompleteSchema.index({user: -1, createdAt: -1});
|
||||
CompleteSchema.index({torrent: 1, createdAt: -1});
|
||||
|
||||
mongoose.model('Complete', CompleteSchema);
|
||||
Reference in New Issue
Block a user