Skip to main content

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.

Continue with The addRelation function.