cubos / sdkgen

[ DEPRECATED, SEE https://github.com/sdkgen/sdkgen ] Tool that aims on solving client-server communication and data layout sharing between server, web, android and ios using a description language also called sdkgen.
MIT License
45 stars 9 forks source link

Make sdkgen database agnostic #2

Closed lbguilherme closed 6 years ago

lbguilherme commented 6 years ago

Fate of api_calls need to be decided. Maybe we can have database plugins.

edgardleal commented 6 years ago

I think in some thing like a DatabaseInterface . The user can make your own DatabaseInterface and pass it to api. If nothing is provided the api will use the default implementation using rethinkdb.

export interface DatabaseInterface {
     loadData(params: any) => Promise<any>;
     saveData(obj: any) => Promise<any>;
     etc...
}

export defineDatabaseImplementation(db: DatabaseInterface) {
   ...
}
lbguilherme commented 6 years ago

By default the sdkgen will generate api code that uses RethinkDB for

  1. healthcheck
  2. saving the device info
  3. locking and saving api calls.

But you can specify the option $useRethink = false to generate nothing related to the database and implement those 3 functions with working "no op"s.

The above functions can still be implemented with the exposed api.hooks.

I'm closing this issue as fixed.