Skip to content

Simplify the way we create schemas, models and types #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ecarriou opened this issue Mar 18, 2018 · 0 comments
Closed

Simplify the way we create schemas, models and types #62

ecarriou opened this issue Mar 18, 2018 · 0 comments
Assignees

Comments

@ecarriou
Copy link
Member

ecarriou commented Mar 18, 2018

Important note: these modifications will not break the current APIs behaviors.

We simplify the way we create schemas, models and types. It works well for defining simple classes and structure. Example:

const mm = runtime.require('metamodel');

// defining a schema
mm.schema('Person', {
  firstName: 'property',
  address: 'property'
});

// overriding the generated model
mm.model('Person', {
  firstName: 'string',
  address: 'address'
});

// defining a new type
mm.type('address', {
  street: 'string',
  city: 'string'
});

// defining an enumeration type
mm.type('city', [
  'Paris',
  'Rennes'
]);

// model creation
mm.create();

// get the class
const Person = runtime.require('Person');

// create an instance
const person = new Person({
  firstName: 'a name',
  address: {
    street: 'a street',
    city: 'Rennes'
  }
});

// use instance
person.address().street();
@ecarriou ecarriou self-assigned this Mar 18, 2018
@ecarriou ecarriou changed the title Minot improvements Minor improvements Mar 18, 2018
@ecarriou ecarriou changed the title Minor improvements Simplify the way we create schemas, models and types Mar 25, 2018
ecarriou added a commit that referenced this issue Mar 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant