Skip to content

Commit f873339

Browse files
authored
docs: update schema examples in schematypes.md
- replace outdated schema examples with relevant ones - correct description of how doubles are stored in MongoDB
1 parent ad418a0 commit f873339

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

docs/schematypes.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -654,16 +654,16 @@ typeof question.answer; // 'bigint'
654654
### Double {#double}
655655

656656
Mongoose supports [64-bit IEEE 754-2008 floating point numbers](https://en.wikipedia.org/wiki/IEEE_754-2008_revision) as a SchemaType.
657-
Int32s are stored as [BSON type "double" in MongoDB](https://www.mongodb.com/docs/manual/reference/bson-types/).
657+
Doubles are stored as [BSON type "double" in MongoDB](https://www.mongodb.com/docs/manual/reference/bson-types/).
658658

659659
```javascript
660-
const studentsSchema = new Schema({
661-
id: Double
660+
const temperatureSchema = new Schema({
661+
celsius: Double
662662
});
663-
const Student = mongoose.model('Student', schema);
663+
const Temperature = mongoose.model('Temperature', temperatureSchema);
664664

665-
const student = new Temperature({ celsius: 1339 });
666-
typeof student.id; // 'number'
665+
const temperature = new Temperature({ celsius: 1339 });
666+
typeof temperature.celsius; // 'number'
667667
```
668668

669669
There are several types of values that will be successfully cast to a Double.
@@ -688,12 +688,12 @@ Mongoose supports 32-bit integers as a SchemaType.
688688
Int32s are stored as [32-bit integers in MongoDB (BSON type "int")](https://www.mongodb.com/docs/manual/reference/bson-types/).
689689

690690
```javascript
691-
const studentsSchema = new Schema({
691+
const studentSchema = new Schema({
692692
id: Int32
693693
});
694-
const Student = mongoose.model('Student', schema);
694+
const Student = mongoose.model('Student', studentSchema);
695695

696-
const student = new Temperature({ celsius: 1339 });
696+
const student = new Student({ id: 1339 });
697697
typeof student.id; // 'number'
698698
```
699699

0 commit comments

Comments
 (0)