big refactor: now we can build document with relations and multi-fields