MongoDB.live, free & fully virtual. June 9th - 10th. Register Now

How to set a documents field read-only?

Hi,
I have 2 questions:

  1. Through Atlas or Compas UI, The objectID field is write protected. Meaning you cannot modify it, how can I do the same on any other document field?
  2. For Atlas, is it possible to link your own S3 storage?

Hi @Student_al_St,

The _id value cannot be modified because it is the unique primary key for a document. In a cluster environment _ids are used in the replication oplog to identify data changes. Modifying the _id value would compromise the idempotent design guarantee of the current oplog format: operations must produce the same results whether applied once or multiple times to the target dataset.

You cannot mark other fields as read-only or protected at a server level. If there is a more natural unique (and immutable) value for your documents, you can provide your own value for _id on insertion instead of using the default ObjectID.

Primary storage in Atlas is part of the managed service.

If you have existing data in S3 in other formats such as JSON, BSON, CSV, Avro, or Parquet you might be interested in using Atlas Data Lake to query this data.

Regards,
Stennie