vadimdemedes / mongorito

🍹 MongoDB ODM for Node.js apps based on Redux
1.38k stars 90 forks source link

Access document's fields without using .get/.set #200

Open LennyPenny opened 6 years ago

LennyPenny commented 6 years ago

Is there a plan for this so documents could be used more natively?

i.e.

let user = await User.findOne();

user.name = user.name + " test";

user.save()

I'm not familiar with your current implementation, but it could probably be easily implemented using proxies

vadimdemedes commented 6 years ago

Yes, I think it's ok to implement this now since proxies have good Node.js support now.

LennyPenny commented 6 years ago

Sadly I'm having trouble implementing this because I'm not really familiar with the underlying react stuffs

https://vgy.me/dhLqE8.png

Could you point me in the right direction?

vadimdemedes commented 6 years ago

Hm, yeah, I did a little research and I don't think it's possible to implement that feature with a Proxy. Seems there's no clean solution for it. Plus it's not worth all the effort to just save a few chars.