How to embed two schema's in ecto?

ecto
changesets
phoenix
#1

I am using Mongodb for database ,lets say i need to insert/update document like follow

{
   "name" : "hariharasudhan", 
   "age" : "22",
   "address" : {
      "line1" : "XXX",
      "line2" : "yyyy"
   }
}

i have separate users and address models, how can i embed address model into user without creating new id for address schema and how can i validate changeset

Note:

my ecto version is 3, So i am using mongodb_driver instead of mongodb_ecto

#2

I would do without ecto. The so-called ORM frameworks are intended to abstract and simplify access. But usually the opposite is the case. Simple situations become real battles against the framework. So why put a framework between the driver and the business logic? If you call the functions of the driver, then you simply get maps of the data back. With the maps can work great. Pattern matching is great. I have several application without ecto or other ORM things and I can do anything I want. Do not worry, I will not change the database. That would usually be an argument to apply an ORM framework. You replace the driver and everything works. But these ORM frameworks are practically just for relational database. Since MongoDB is not a relational database, this approach works only conditionally. To be honest, it does not work at all. Without ORM framework access to a database? Yes, it works and he feels good. Do not panic, I know what I’m talking about. I have known ORM framework since WebObjects with EOF. This was a framework that was really great. Everything else that came afterwards was just a tired imitation (Reinventing the wheel). But we are talking about MongoDB and not a relational database. Just try the things out and check the result yourself. So: Stay Hungry. Stay Foolish.