Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema Definition Options #1

Open
bstahlhood opened this issue Mar 25, 2019 · 1 comment
Open

Schema Definition Options #1

bstahlhood opened this issue Mar 25, 2019 · 1 comment

Comments

@bstahlhood
Copy link

bstahlhood commented Mar 25, 2019

In Mongoose, you can pass options to a schema definition such as toJSON, toObject, timestamps, and id. How do you pass these with the schema definition?

@medolino
Copy link

medolino commented Nov 2, 2020

You can pass schema options under models[].options.

Example:

{
  ...,
  models: [
    {
      name: "posts",
      alias: "Post",
      schema: {
        title: {
          type: String,
          required: true,
        },
        ...
      },
      // add schema configurable options
      options: {
        timestamps: true,
        ...
      }
    },
    ...
  ]
}

@alex-ppg I think it would be usefull to include this information in README.md example.
If you are interested, I created a pull request #11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants