-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add schemas for series, movies and user
- Loading branch information
Araan Branco
committed
Mar 10, 2017
1 parent
93b6cce
commit 6c63c60
Showing
8 changed files
with
214 additions
and
4 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
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,28 @@ | ||
|
||
import * as db from '../helpers/db'; | ||
import Debug from 'debug'; | ||
|
||
const debug = Debug('sofanerd.models'); | ||
|
||
const register = (server, options, next) => { | ||
const dbConenction = db.connect('sofanerd').connection; | ||
|
||
debug('Models initialize'); | ||
require('./movie').model(dbConenction); | ||
require('./serie').model(dbConenction); | ||
require('./user').model(dbConenction); | ||
|
||
debug('Models registered'); | ||
|
||
next(); | ||
}; | ||
|
||
register.attributes = { | ||
name: 'models', | ||
multi: false, | ||
once: true | ||
}; | ||
|
||
export default { | ||
register | ||
}; |
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,9 @@ | ||
|
||
import Debug from 'debug'; | ||
import schema from './schemas/movie'; | ||
|
||
const debug = Debug('sofanerd.models.movie'); | ||
|
||
export const model = (connection) => { | ||
return connection.model('Movie', schema); | ||
}; |
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,72 @@ | ||
|
||
import mongoose from 'mongoose'; | ||
|
||
const Schema = mongoose.Schema; | ||
|
||
const schema = new Schema({ | ||
id_imdb: { | ||
type: Number | ||
}, | ||
name: { | ||
type: String, | ||
required: true | ||
}, | ||
slug: { | ||
type: String | ||
}, | ||
description: { | ||
type: String | ||
}, | ||
year: { | ||
type: Number | ||
}, | ||
genre: { | ||
type: String | ||
}, | ||
country: { | ||
type: String | ||
}, | ||
director: { | ||
type: String | ||
}, | ||
writer: { | ||
type: String | ||
}, | ||
trailer: { | ||
type: String | ||
}, | ||
published: { | ||
type: Array | ||
}, | ||
featured: { | ||
type: Array | ||
}, | ||
checkins: [{ | ||
user_id: { | ||
type: Schema.Types.ObjectId, | ||
ref: 'User' | ||
}, | ||
created_at:{ | ||
type: Date, | ||
default: Date.now | ||
} | ||
}], | ||
reactions: [{ | ||
user_id: { | ||
type: Schema.Types.ObjectId, | ||
ref: 'User' | ||
}, | ||
note: { | ||
type: Number | ||
}, | ||
created_at:{ | ||
type: Date, | ||
default: Date.now | ||
} | ||
}], | ||
favorites: [], | ||
collections: [], | ||
comments: [] | ||
}); | ||
|
||
export default schema; |
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
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
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 |
---|---|---|
@@ -1,4 +1,9 @@ | ||
|
||
import Debug from 'debug'; | ||
import schema from './schemas/serie'; | ||
|
||
const debug = Debug('sofanerd.models.serie'); | ||
const debug = Debug('sofanerd.models.serie'); | ||
|
||
export const model = (connection) => { | ||
return connection.model('Serie', schema); | ||
}; |
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 |
---|---|---|
@@ -1,4 +1,9 @@ | ||
|
||
import Debug from 'debug'; | ||
import schema from './schemas/user'; | ||
|
||
const debug = Debug('sofanerd.models.user'); | ||
const debug = Debug('sofanerd.models.user'); | ||
|
||
export const model = (connection) => { | ||
return connection.model('User', schema); | ||
}; |