Docs Menu

Docs HomeRealm

Define an Asymmetric Object - React Native SDK

On this page

  • Overview

If you are using Flexible Sync and need to sync a collection unidirectionally from your device to your Atlas database, you can set the asymmetric property on your object schema.

Example

In the following example of a retail app, the client requires large amounts of invoice data to be recorded rapidly by store employees. The client specifies that invoice data does not need to be read after employees have recorded it. To satisfy this requirement, the application developer defines an invoice collection with its asymmetric property set to true.

const InvoiceSchema = {
name: "Invoice",
// sync Invoice objects one way from your device to your Atlas database.
asymmetric: true,
primaryKey: "_id",
properties: {
_id: "objectId",
item: "string",
quantity: "int",
price: "int",
},
};

Note

Attempting to Read Asymmetric Sync Objects

Asymmetric Sync objects cannot be read. If you attempt to query an Asymmetric Sync object, you will get the following error: "Error: You cannot query an asymmetric class.".

To learn more about Asymmetric Sync, read Optimize Sync with Asymmetric Sync.

←  Embedded Objects - React Native SDKOpen & Close a Realm - 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.