Docs Menu

Docs HomeRealm

Define a Default Property Value - React Native SDK

On this page

  • Overview

To define a default value, set the value of the property to an object with a type field and a default field.

Example

The following Car object schema specifies a default value of 0 for the miles property:

const CarSchema = {
name: "Car",
properties: {
make: "string",
model: "string",
miles: { type: "int", default: 0 },
},
};
←  Index a Property - React Native SDKRemap a Property - React Native SDK →

On this page

Share Feedback
© 2023 MongoDB, Inc.

About

  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2023 MongoDB, Inc.