Skip to content

Commit 0292a68

Browse files
committed
update schema example to use sequelize
1 parent 0bccf7e commit 0292a68

File tree

1 file changed

+15
-9
lines changed
  • module3-crud-and-data-models/r1-schema-and-data-models

1 file changed

+15
-9
lines changed

module3-crud-and-data-models/r1-schema-and-data-models/README.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,24 @@ const customer = new mongoose.Schema({
1717
},
1818
});
1919

20-
module.exports = mongoose.model("Customer", customer);
20+
module.exports = mongoose.model("customer", customer);
2121
```
2222

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.
3124

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+
};
3238
```
3339

3440
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`.

0 commit comments

Comments
 (0)