Skip to content

Commit

Permalink
Merge pull request #11 from OrcaPracticas/add/schemas
Browse files Browse the repository at this point in the history
📝 Desarrollo de schemas
  • Loading branch information
konami12 authored Jun 21, 2020
2 parents d410041 + e94864e commit 696ec71
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/src/models/index.js
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";
31 changes: 31 additions & 0 deletions app/src/models/pokemon.js
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);
16 changes: 16 additions & 0 deletions app/src/models/user.js
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);

0 comments on commit 696ec71

Please sign in to comment.