3

In many of the previous Waterline databases that I've hacked around with, you could create a Waterline/Sails model using the "generic" syntax specified by Waterline/Sails and things would just work. When I started using OrientDB and Waterline-OrientDB there appears to be an issue whereby I have to define my full schema in OrientDB before I am able to persist anything. Is this a requirement for using Waterline-OrientDB or is there something not configured properly about my OrientDB setup which is forcing the schema to be defined first.

If the creation is necessary, how should one model the edges in the OrientDB database and in SailsJS to ensure that the Sails/Waterline ORM will be able to persist properly. I assumed that it would "just work", but throughout the waterline-orientdb documentation are references to calls for creating edges and such. That seems to be a crucial feature from the documentation - what do you HAVE to define, and what can you get away with not defining for SailsJS model objects.

Dário
  • 2,002
  • 1
  • 18
  • 28
AfroRick
  • 610
  • 5
  • 17
  • I think this might be better asked to the folks who designed sails-orientdb adapter. I know nothing about orientdb. – Travis Webb Mar 24 '15 at 05:58
  • Hi @Travis, I believe @Guardius refers to "waterline-orientdb" adapter and not "sails-orientdb" adapter which are [different adapters](http://stackoverflow.com/questions/27368083/how-to-use-orientdb-in-a-sailsjs-app/28754421#28754421). My understanding is that the schema is not being created due to the `migrate` option. I've given my complete answer below. – Dário Mar 24 '15 at 13:40

1 Answers1

2

No waterline model definition or config have been provided, so it's hard to pinpoint what the exact issue is. One possible cause is that migrate is set to 'safe' in the config. waterline-orientdb follows the migratable interface and as such it will only create classes when migrate: 'drop' or migrate: 'alter' (waterline deems this as experimental) or migrate: 'create' (in waterline master branch, not released yet). More about setting the migrate options on Sails.js docs - model settings.

Regarding the second paragraph, waterline-orientdb complies 100% to the waterline specification and it passes all API integration tests for Waterline adapters (results). Edges are modelled as normal waterline many-to-many associations. The waterline-orientdb documentation follows the example of other adapters as it mostly documents things that are particular to waterline-orientdb, namely extensions made. In other words waterline-orientdb can be used just like any other adapter and these extensions are just to help with specific OrientDB operations.

Let me know if this doesn't fix your issue and feel free to provide examples, I'll look into them.

Dário
  • 2,002
  • 1
  • 18
  • 28
  • Yep. This is where the issue lay. Migrate was being forced to 'safe' and that was preventing the system from working properly. I did get a bunch of errors when trying to set it to 'alter', but that's fine since I really want to either use 'drop' when developing or 'safe' when in production – AfroRick Mar 24 '15 at 15:25
  • Good to hear that fixed the issue. Feel free to report any issues on the [github project page](https://github.com/appscot/waterline-orientdb) and I'll look at them once I have a chance. Regards – Dário Mar 24 '15 at 16:26