Skip to content

Latest commit

 

History

History
78 lines (50 loc) · 1.67 KB

Readme.md

File metadata and controls

78 lines (50 loc) · 1.67 KB

Rodin

/roʊˈdæn/

This is an object modeling tool for MongoDB, based on mongo dart.

This library is not yet finished! Do not use.

The name comes from Auguste Rodin who was a french sculptor.

Status

  • Define models
  • Define subcollections
  • Query for records with myModel.find()
  • Insert records
  • Update records
  • Delete records
  • Use specifications such as index, requied, compound index, etc...
  • Add a validation system

Metadata (annotations)

Until reflection for metadata is possible in dart, the configuration for Models is a bit noisy and temporary.

This is how you'll define the models as soon as it's done:

@CompoundIndex({ "firstName": Direction.ASC, "lastName": Direction.DESC })
class UserModel extends Model {

  @Required()
  @Unique()
  String username;
  
  String firstName;

  String lastName;

}

UserModel user = new UserModel()
  ..username = "enyo"
  ..firstName = "Matias"
  ..lastName = "Meno"
  ..insert(); // And insert the record in the database.
 

For now you'll have to specify the specifications like this:

class UserModel extends Model {

  String username;
  
  String firstName;

  String lastName;

  static Map<String, List<Specification>> specifications = {
    "_MODEL_": [ const CompoundIndex(const { "firstName": Direction.ASC, "lastName": Direction.DESC }) ],
    "username": [ const Required(), const Unique() ]
  };
}

Other database

The database implementation of rodin is very decoupled of the rest. So it isn't difficult to write other database adapters for it. I might extend it for other databases some day.