Within my "users" collection, I have two objects named "user1" and "user2", each containing fields for avatar, friends, name, and potentially other information.
The crux of my question lies in the "friends" field within the "user2" object. This field is an array that includes an object {name: user1, avatar: db.users.user 1.avatar}. Essentially, I am aiming to establish a link to user1's avatar within this object in the avatar field.
To illustrate, imagine the following structure:
user1 : { avatar : "link on avatar", name: "user1", friends: [] },
user2 : { avatar : "link on avatar", name: "user1", friends: [{name: "user1", avatar: ??? }] }
Here, the question marks denote where the link to user1's avatar should be inserted.
I am seeking a way to achieve this directly in MongoDB without relying on Node.js for implementation.
I find myself uncertain about how to proceed with this task, as it presents a unique challenge given my constraints.