Categories
JavaScript Answers

How to save array of strings with Node Mongoose?

Spread the love

To save array of strings with Node Mongoose, we put the data type in an array.

For instance, we write

const personSchema = new mongoose.Schema({
  tags: [
    {
      type: String,
    },
  ],
});

to add the tags field to the personSchema and make it a string array field with

[
  {
    type: String,
  },
];

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *