There are no items in your cart
Add More
Add More
Item Details | Price |
---|
Mon Jan 3, 2022
In Mongoose, you can store an array in a field by defining the field as an array type in your schema. For example:
const mongoose = require('mongoose'); const schema = new mongoose.Schema({ myArray: [Number] }); const MyModel = mongoose.model('MyModel', schema);
This will create a new Mongoose model called "MyModel" with a field called "myArray" that can store an array of numbers.
You can also use the mongoose.Schema.Types.Array
to define the array field
const mongoose = require('mongoose'); const schema = new mongoose.Schema({ myArray: {type: mongoose.Schema.Types.Array} }); const MyModel = mongoose.model('MyModel', schema);
This will create a new Mongoose model called "MyModel" with a field called "myArray" that can store any array.
DCT Academy
Full Stack web development training institute in Bangalore