-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f89038
commit 484c087
Showing
2 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
'use strict'; | ||
|
||
/** | ||
* Module dependencies | ||
*/ | ||
var mongoose = require('mongoose'), | ||
Schema = mongoose.Schema; | ||
|
||
/** | ||
* Peer Schema | ||
*/ | ||
var PeerSchema = new Schema({ | ||
user: { | ||
type: Schema.ObjectId, | ||
ref: 'User' | ||
}, | ||
passkey: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
info_hash: { | ||
type: Buffer, | ||
default: '' | ||
}, | ||
peer_id: { | ||
type: Buffer, | ||
default: '' | ||
}, | ||
peer_compact: { | ||
type: Buffer, | ||
default: '' | ||
}, | ||
peer_ip: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
peer_port: { | ||
type: Number, | ||
default: 0 | ||
}, | ||
peer_uploaded: { | ||
type: Number, | ||
default: 0 | ||
}, | ||
peer_downloaded: { | ||
type: Number, | ||
default: 0 | ||
}, | ||
peer_seeder: { | ||
type: [{ | ||
type: String, | ||
enum: ['yes', 'no'] | ||
}], | ||
default: 'no' | ||
}, | ||
peer_connectable: { | ||
type: [{ | ||
type: String, | ||
enum: ['yes', 'no'] | ||
}], | ||
default: 'no' | ||
}, | ||
startedat: { | ||
type: Date, | ||
default: Date.now | ||
}, | ||
finishedat: { | ||
type: Date, | ||
default: '' | ||
} | ||
}); | ||
|
||
PeerSchema.index({user: -1, startedat: -1}); | ||
PeerSchema.index({info_hash: -1, startedat: -1}); | ||
PeerSchema.index({passkey: -1, startedat: -1}); | ||
|
||
mongoose.model('Peer', PeerSchema); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
'use strict'; | ||
|
||
/** | ||
* Module dependencies | ||
*/ | ||
var mongoose = require('mongoose'), | ||
Schema = mongoose.Schema; | ||
|
||
/** | ||
* Torrent Schema | ||
*/ | ||
var TorrentSchema = new Schema({ | ||
user: { | ||
type: Schema.ObjectId, | ||
ref: 'User' | ||
}, | ||
info_hash: { | ||
type: String, | ||
default: '', | ||
trim: true, | ||
required: 'info_hash cannot be blank' | ||
}, | ||
torrent_title: { | ||
type: String, | ||
default: '', | ||
trim: true, | ||
required: 'title cannot be blank' | ||
}, | ||
torrent_type: { | ||
type: String, | ||
default: 'movie', | ||
trim: true | ||
}, | ||
torrent_tags: { | ||
type: String, | ||
default: '[0]', | ||
trim: true | ||
}, | ||
torrent_desc: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
torrent_announce: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
torrent_seeds: { | ||
type: Number, | ||
default: 0 | ||
}, | ||
torrent_leechers: { | ||
type: Number, | ||
default: 0 | ||
}, | ||
torrent_finished: { | ||
type: Number, | ||
default: 0 | ||
}, | ||
torrent_size: { | ||
type: Number, | ||
default: 0 | ||
}, | ||
torrent_img: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
last_scrape: { | ||
type: Date, | ||
default: Date.now | ||
}, | ||
createdat: { | ||
type: Date, | ||
default: Date.now | ||
} | ||
}); | ||
|
||
TorrentSchema.index({user: -1, createdat: -1}); | ||
TorrentSchema.index({info_hash: -1, createdat: -1}); | ||
|
||
mongoose.model('Torrent', TorrentSchema); |