forked from DemocraciaEnRed/pp-mgp
-
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.
- Loading branch information
Showing
3 changed files
with
61 additions
and
14 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,27 @@ | ||
const mongoose = require('mongoose') | ||
const Schema = mongoose.Schema | ||
|
||
const ClaustroSchema = new Schema({ | ||
nombre: { type: String, required: true, minlength: 1, maxlength: 200 } | ||
}, { id: false }) | ||
// esto último hace que no esté el campo _id e id duplicado | ||
|
||
ClaustroSchema.statics.findByName = function (name, cb) { | ||
return this.findOne({ name: name }).exec(cb) | ||
} | ||
|
||
/** | ||
* Make Schema `.toObject()` and | ||
* `.toJSON()` parse getters for | ||
* proper JSON API response | ||
*/ | ||
|
||
ClaustroSchema.set('toObject', { getters: true }) | ||
ClaustroSchema.set('toJSON', { getters: true }) | ||
/** | ||
* Expose Model | ||
*/ | ||
|
||
module.exports = function initialize(conn) { | ||
return conn.model('Claustro', ClaustroSchema) | ||
} |
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