redstone-dart / redstone

A metadata driven microframework for Dart.
http://redstone-dart.github.io/redstone
MIT License
342 stars 42 forks source link

redstone_mongo_client #87

Closed cgarciae closed 8 years ago

cgarciae commented 9 years ago

I have POST, PUT, GET, and DELETE routes inside MongoDBServices with app.Group that do the obvious for most of my database objects. Taking the MeteorJS approach to create a MongoDB client on the client/browser would take this pain away. The idea would be to create a single group (/mongoServices) that handles all the MongoDb requests (/mongoServices/:collection/find, /mongoServices/:collection/insert, etc), and create an object on the client that requests to those routes.

The idea is that you'd be able to write code like this on the client

MongoClient<User> userClient = new MongoClient<User>('user');
userClient.findOne ({'_id': someId}).then ((User user) => ...);

or more generally

DbCollection userCollection= new DbCollection ('user');
userCollection.findOne ({'_id': someId}).then ((Map result) => ...);

Given that Mongo is almost JSON, the real issue would be more authorization and security: you'd have to be able to restrict find and update given the permissions of the user over the collection.

I'll give it a try one of this days and how it plays out. Whats your take on this?

Pacane commented 8 years ago

@cgarciae Are you still working on this? I have worked on mongo_dart and I might be able to help you if this is still a thing.