Document schema for LinkingObjects


I’m trying to define a data structure that uses relationships.
The data model is defined as follows on the iOS code.

class Node : Object {
      @objc dynamic var _id:String = ""
      @objc dynamic var _partition: String = ""
      var children = List<Node>()
      var parents = LinkingObjects(fromType: Node.self, property: "children")

MongoDB-atlas Json scheme is defined as follows.

  "bsonType": "object",
  "properties": {
    "_id": {
      "bsonType": "string"
    "_partition": {
      "bsonType": "string"
    "children": {
      "bsonType": "array",
      "items": {
        "bsonType": "string"
  "required": [
  "title": "Node"


  "children": {
    "ref": "#/relationship/mongodb-atlas/node_test/Node",
    "foreign_key": "_id",
    "is_list": true

But ios app can’t access children’s parent.

let parent = Node() 
let child = Node()
try! realm.commitWrite()
print(parent.childen.first?.parents) // this result is “nil” 

The child’s parent reference isn’t stored in the Atlas collection.
The parent’s children reference is stored.

Development mode is turned on. There is no particular schema description for “LinkingObject”.
If I want to have an inverse relationship, do I need to set anything else in the mongo db atlas Json schema?

1 Like