restberry icon indicating copy to clipboard operation
restberry copied to clipboard

Is it possible to use on a Relational Database

Open alber70g opened this issue 9 years ago • 2 comments

First a question: is it possible to do this on relational databases as well? For example mysql/maria or postgres?

Next I have some ideas: I really like the idea of declaring what it should do, instead of writing how it should do it. Especially for writing a light backend for a SPA frontend for example

I've been working on something alike where you define an object on which the request should match and then some optional middleware. It's easier to show it by example:

app.on({ method: 'POST' }, function(req, res, next) { 
  // perform some logic (authorization rules for example)
  next(); // calling next will eventually call the middleware that handles the database
}

This way you define what it should do instead of on which route etc. If you want I can share a very premature draft with you.

alber70g avatar Feb 14 '17 23:02 alber70g

Sure. that sounds interesting.

For your first question, it should be possible. What you have to do is to write a plugin like restberry-mongoose but instead restberry-mysql or restberry-postgres. You could give it a try if you like :)

materik avatar Feb 15 '17 08:02 materik

Have a look at https://github.com/Alber70g/middlerestjs

I haven't been doing much with nodejs, so bear with me. Also this is a very early writedown of what the idea is. I welcome any suggestions. Maybe we can integrate the idea inside restberry, since this project is much more mature

alber70g avatar Feb 15 '17 08:02 alber70g