Skip to content

The big refactor ("2.0")

Compare
Choose a tag to compare
@dmarcelino dmarcelino released this 26 Feb 18:54
· 169 commits to master since this release

Changes

  • Many-to-many join tables are now edges (#29)
  • Make code simpler by alleviating connection.js and creating a new class Collection. Collection itself can be a Document, Edge or Vertex. This makes it simpler to segregate class logic and to extend behaviour.
  • Support Syncable
  • Support interface "migratable"
  • Improve code coverage
  • Add more tests
  • Move all default configs to adapter
  • Add support to document databases (in addition to graph dbs)
  • orientdbClass: ability to force a model to be a given class
  • decodeURIComponent config, when enabled id is decoded (makes it sails/blueprints friendly)
  • support schemaless: actually pay attention to the schema flag to avoid the need for hacks like this.

Notes

Given the size and extension of these changes it's possible that this new version will behave differently in extreme scenarios. All has been done to mitigate that, including adding more automated tests. Changes to be aware:

Associations: many-to-many join tables will now be edges

If database type is set to graph then waterline-orientdb will use edges instead of join tables.

Migratabable

One change to be aware is the way waterline-orientdb will handle classes creation at start up. In the past waterline-orientdb would not touch existing classes and would create missing ones. Now it conforms to the waterline Auto Migration Strategies:

  • "safe" (default in production env)
    • do nothing
  • "drop" (default in development env)
    • drop all tables and recreate them each time the server starts-- useful for development
  • "alter"
    • experimental automigrations
orientdbClass

From now on it will be possible to force the class of a model by adding the property orientdbClass to the definition. Generally this is not required as waterline-orientdb can determine which is the best class to use, so it should only be used in special cases. Possible values:

  • undefined - waterline-orientdb will determine which class to use. In graph dbs it will be vertex for non junction collections and edge for association junction tables
  • "" or "document" - class will be the default OrientDB document class;
  • "V"- class will be Vertex;
  • "E"- class will be Edge.

Example:

{
  identity : 'post',
  orientdbClass : 'V'

  attributes : {
    name : 'string'
  }
}

Note, when using a document database (through config.options.databaseType), orientdbClass class will be ignored and all classes will be documents