Skip to content

Commit 696ec71

Browse files
authored
Merge pull request #11 from OrcaPracticas/add/schemas
📝 Desarrollo de schemas
2 parents d410041 + e94864e commit 696ec71

3 files changed

Lines changed: 49 additions & 0 deletions

File tree

app/src/models/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default as Pokemon } from "./pokemon";
2+
export { default as User } from "./user";

app/src/models/pokemon.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { model as Model, Schema } from "mongoose";
2+
3+
/**
4+
* Esquema correspondiente al registro de un pokemon.
5+
*
6+
* @return {Mongoose Schema}.
7+
*/
8+
const SCHEMA = new Schema({
9+
abilities: [String],
10+
evolution: [String],
11+
height: { type: String, default: "0′0″ (0.0m)" },
12+
name: { type: String, required: true },
13+
species: { type: String, required: true },
14+
stats: {
15+
attack: Number,
16+
defense: Number,
17+
hp: Number,
18+
sp: {
19+
atk: Number,
20+
def: Number,
21+
},
22+
speed: Number,
23+
total: Number,
24+
},
25+
types: [String],
26+
weight: { type: String, default: "0 lbs (0 kg)" },
27+
img: { type: String, default: "https://pbs.twimg.com/profile_images/1155697750664609802/ClNE-F8S_400x400.jpg" },
28+
});
29+
30+
// Se indica el nombre de la colección y esquema a utillizar
31+
export default Model("pokemons", SCHEMA);

app/src/models/user.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { model as Model, Schema } from "mongoose";
2+
3+
/**
4+
* Esquema correspondiente al registro de un user.
5+
*
6+
* @return {Mongoose Schema}.
7+
*/
8+
const SCHEMA = new Schema({
9+
name: { type: String, required: true },
10+
lastName: { type: String, required: true },
11+
email: { type: String, required: true },
12+
phoneNumber: { type: String, default: "00-00-00-00-00" },
13+
});
14+
15+
// Se indica el nombre de la colección y esquema a utillizar
16+
export default Model("user", SCHEMA);

0 commit comments

Comments
 (0)