O'Reilly logo

Hands-On Full Stack Web Development with Aurelia by Erikson Haziz Murrugarra Sifuentes, Diego Jose Arguelles Rojas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Defining schemas

To store information in our database we need to create a model, this model is created based on a initial schema definition. This schema definition contains the attributes and datatypes of the information we want to store. Let's define the schema for our collections of teams. In the same mongoose-connection.js file, add the following code:

...const TeamSchema = new mongoose.Schema({  name: String,  ranking: Number,  captain: String,  trainer: String,  confederation: String})

As you can see, defining schemas is straightforward. We use the mongoose.Schema object and define the fields we want for our schema as a JSON object.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required