Basic model example using ecto without database

I will be watching it again this weekend with an iex open to play/learn.

What I am after, other than an excuse to use elixir, is a replacement for some Dart code generation. I have outlined my current task in a previous question to both elixir and clojure communities to help me select a good replacement language. I’m happy with what I’m seeing in elixir and will use it.

I’m trying to decide between using elixir embedded schema or rolling my own modules which I previously implemented in Dart. My focus on in-memory was poorly worded because it’s less about that and more about not wanting the weight of a database. So your talk was a perfect intro. I have maybe 50 schemas and a total of less than 1,000 instances stored in the flat files that I translate via code generation into Rust and other target languages. I can easily edit the instances and regenerate the code. I don’t need any complex queries, just ability to iterate on fields and maybe filter. So the process is like protobufs, capnp, thrift, etc just focusing on the structure and not behavior.

I do like the look of ecto definitions but I’m not sure yet on how to specify/store instances of the schemas conveniently in flat file. From what I gather the choices are basic elixir literal syntax or use json/yaml with ecto as the Mapper.

So, for the sample above the schema in Dart code looks like:

  enum_('person_type', [
    ev('primary_owner', 'The primary owner of the `Dossier`'),
    ev('secondary_owner', 'The secondary owner of the `Dossier`'),
    ev('dependent', 'A dependent - as in child')
  ])
    ..doc = 'Used to categorize people covered by `Dossier`',

  object('age_assumptions', [
    field('retirement_age', Int32)
      ..doc = '''
Age of retirement - where labor incomes are ended.
''',
    field('death_age', Int32)
      ..doc = '''    
Age at death.''',
  ])
    ..doc = '''
Assumptions regarding the ages of a person _at retirement_, _at death_, etc.'''
    ..setProperty('rust_own_module', true)
    ..setProperty('rust_not_derives', ['Default']),

  object('person', [
    field('id')..doc = 'Identifier for the person (eg name or nom de guerre)',
    anonymousField('person_type')..doc = 'Type of person',
    field('birth_year', Int32)..doc = 'Year of birth of person',
    anonymousField('age_assumptions')
      ..doc = 'Important ages for person'
      ..isOptional = true,
  ])
    ..doc = '''
Captures just enough about the `Person` to forecast.
Ability to determine age is important for determining timing of
events - like RMD requirements, statistics on costs such as healthcare,
etc
'''
    ..setProperty('rust_own_module', true),

The code generation turns it into the rust previously shown. So now I want to either convert those schema into elixir embedded schema or just port my existing libraries from Dart. Either way I’ll have to decide how to store my instances of the schemas as elixir literals or json. Any suggestions there would help.