-
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.
Merge pull request #11 from OrcaPracticas/add/schemas
📝 Desarrollo de schemas
- Loading branch information
Showing
3 changed files
with
49 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,2 @@ | ||
export { default as Pokemon } from "./pokemon"; | ||
export { default as User } from "./user"; |
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,31 @@ | ||
import { model as Model, Schema } from "mongoose"; | ||
|
||
/** | ||
* Esquema correspondiente al registro de un pokemon. | ||
* | ||
* @return {Mongoose Schema}. | ||
*/ | ||
const SCHEMA = new Schema({ | ||
abilities: [String], | ||
evolution: [String], | ||
height: { type: String, default: "0′0″ (0.0m)" }, | ||
name: { type: String, required: true }, | ||
species: { type: String, required: true }, | ||
stats: { | ||
attack: Number, | ||
defense: Number, | ||
hp: Number, | ||
sp: { | ||
atk: Number, | ||
def: Number, | ||
}, | ||
speed: Number, | ||
total: Number, | ||
}, | ||
types: [String], | ||
weight: { type: String, default: "0 lbs (0 kg)" }, | ||
img: { type: String, default: "https://pbs.twimg.com/profile_images/1155697750664609802/ClNE-F8S_400x400.jpg" }, | ||
}); | ||
|
||
// Se indica el nombre de la colección y esquema a utillizar | ||
export default Model("pokemons", 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,16 @@ | ||
import { model as Model, Schema } from "mongoose"; | ||
|
||
/** | ||
* Esquema correspondiente al registro de un user. | ||
* | ||
* @return {Mongoose Schema}. | ||
*/ | ||
const SCHEMA = new Schema({ | ||
name: { type: String, required: true }, | ||
lastName: { type: String, required: true }, | ||
email: { type: String, required: true }, | ||
phoneNumber: { type: String, default: "00-00-00-00-00" }, | ||
}); | ||
|
||
// Se indica el nombre de la colección y esquema a utillizar | ||
export default Model("user", SCHEMA); |