File tree Expand file tree Collapse file tree 1 file changed +15
-9
lines changed
module3-crud-and-data-models/r1-schema-and-data-models Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -17,18 +17,24 @@ const customer = new mongoose.Schema({
17
17
},
18
18
});
19
19
20
- module .exports = mongoose .model (" Customer " , customer);
20
+ module .exports = mongoose .model (" customer " , customer);
21
21
```
22
22
23
- The same ` customer ` schema in a MySQL database.
24
-
25
- ``` sql
26
- CREATE TABLE customer (
27
- id INT AUTO_INCREMENT PRIMARY KEY ,
28
- name VARCHAR (50 ) NOT NULL ,
29
- zipcode INT (15 ) default NULL ,
30
- )
23
+ The same ` customer ` schema in PostgreSQL database using sequelize.
31
24
25
+ ``` js
26
+ module .exports = (sequelize , DataTypes ) => {
27
+ const Customer = sequelize .define (" customer" , {
28
+ name: {
29
+ type: DataTypes .STRING ,
30
+ allowNull: false ,
31
+ },
32
+ zipcode: {
33
+ type: DataTypes .INTEGER ,
34
+ },
35
+ });
36
+ return Customer;
37
+ };
32
38
```
33
39
34
40
We can see that the schema definition for the ` customer ` has a ` name ` that is type ` string ` and a ` zipcode ` that is of type ` number ` .
You can’t perform that action at this time.
0 commit comments