Managing Relations
So far we've created three models โ country, city, and user โ with different relationships between them. Can we update these relationships after the documents already exist?
Yes โ but only through addRelation and removeRelation. Never by hand-editing the embedded relation fields with update or updateMany. Lesan keeps both sides of every relation in sync, and that only works when Lesan manages the change. Let it handle the bookkeeping, and your data always stays correct.
- The
addRelationfunction โ adding new links to existing documents - The
removeRelationfunction โ removing links from existing documents - What is a relation really? See What Is the Relationship Really?
Continue with The addRelation function.