Claudio Pomo Claudio Pomo - 2 months ago 7x
Dart Question

Using objectory with ForceFrameworkMvc

I'm using dart-forcemvc_rest to routing request to my server and serve a json as response.
Today I'm starting to using objectory to query data on my mongo db.
This is great! I can create models to query my collections and use this ones with properties fetched on my db.
This is my model

part of bookshelf;

class user extends PersistentObject with Jsonify{

String get username => getProperty(username);
set username(value) => setProperty(username,value);

String get email => getProperty(email);
set email(value) => setProperty(email,value);

void registerClasses() {
objectory.registerClass(user,()=>new user(),()=>new List<user>());

And this is my controller

part of bookshelf;

class BookController {

Objectory db;

@RequestMapping(value: "/user",method: RequestMethod.GET)
Future countJson(req) {
return db[user].findOne();
return req.asyncFuture;

This uses a async controller feature, but I can't see any response when I call
, I see only
on my browser
enter image description here

I can't understand where is the trouble. Anybody help me?


To answer your question on the most basic level I believe jsonify package just do not treat setter/getter pair as valid substitution for class variable. Take a look at its source code:

On another level - maybe it is just not a great idea to have two totally different persistency middleware layer in one project (namely objectory and jsonify). Objectory has it's own unified approach for client/server communication - currently it presuppose using of web sockets and bson transport. (Use of objectory at the server side is trivial in that respect). See simple web example in package itself or (somewhat outdated) example of full stack application at . If you prefer to use RESTFULL api and json as transport maybe for example would suite you better.

On the other hand I think it would be nice to have RESTFULL variant of objectory client (with json transport) implemented as shelf plugin or something like this. When/if I'll have a spare time I'll see at it - initially it seems to be quite a trivial task but who knows...