mongo-dart / tests / objectory / DomainModel.dart

interface Author extends IPersistent default ObjectoryFactory{
  Author();
  String name;
  int age;
  String email;
}
interface Person extends IPersistent default ObjectoryFactory{
  Person();
  String firstName;
  String lastName;
  Date birthday;
  Address address;  
  Person father;
  Person mother;
}
interface Address extends IPersistent default ObjectoryFactory{
  Address();
  String cityName;
  String zipcode;
  String streetName;
}


class AuthorImpl extends RootPersistentObject implements Author{  
  String get type()=>'Author';
  set name(String value){
    if (value is String){
      value = value.toUpperCase();
    }      
    setProperty('name', value);
  }
  String get name()=>getProperty('name');
}
class PersonImpl extends RootPersistentObject implements Person{  
  String get type()=>"Person";
  init(){
    address = new Address();
//    setProperty("address",new Address());
  }
}  
class AddressImpl extends InnerPersistentObject implements Address{  
  String get type()=>"Address";
}
class ObjectoryFactory{
  factory Author()=>new AuthorImpl();
  factory Person()=>new PersonImpl();
  factory Address()=>new AddressImpl();
}
void registerClasses(){
  objectory.registerClass(new ClassSchema('Author',
      ()=>new Author(),
      ["name","age","email"]));
  objectory.registerClass(new ClassSchema('Address',
    ()=>new Address(),
    ["cityName","zipCode","streetName"]));
  objectory.registerClass(new ClassSchema('Person',
    ()=>new Person(),
    ["firstName","lastName","birthday"],
    components: {"address": "Address"},
    links: {"father": "Person", "mother": "Person"}));
}
final PERSON = 'Person';
final AUTHOR = 'Author';
final ADDRESS = 'Address';
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.