Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting a specific key of an Object-type column #680

Closed
zartre opened this issue Oct 19, 2018 · 10 comments
Closed

Setting a specific key of an Object-type column #680

zartre opened this issue Oct 19, 2018 · 10 comments

Comments

@zartre
Copy link

zartre commented Oct 19, 2018

Is there a way to set a specific key of a column with type Object? I've been trying the code below with no success:

user.set('achievements.firstGame', true);

However, setting it with a whole object works fine.

const achm = { firstGame: true };
user.set('achievements', achm);
@paulovitin
Copy link
Contributor

@flovilmart thats a good feature?! I believe it's a good thing. If ok, I can implement this.

@flovilmart
Copy link
Contributor

Not sure it’s a good feature, nor how it will be implemented server side. So if you want this feature use the mongo driver directly.

@dplewis
Copy link
Member

dplewis commented Oct 27, 2018

@flovilmart I think this would be a great feature, it would also be an atomic operation and mongo / postgres can support it

@flovilmart
Copy link
Contributor

Well it’s probably a confusing one as it’s an atomic update. Unlike increment, if the object is not realized locally,it can backfire.

Again, I don’t believe the job of the SDK is to expose all single mongo and oostges feature but to provide a simple access to the most common ones to enable fast and reliable mobile and web app developments.

You’re free to challenge me and tell me it’s one of the top important things, I just don’t see it this way. For example, push notifications scalability, graphql, more Db adapters would be higher on my list :)

@paulovitin
Copy link
Contributor

@dplewis @flovilmart so I understood the feature is just a way to set objects and would not change anything server and client. As an example, he even showed that he only wants to be able to set an object with dot notation.

@DobaKung am I wrong?

@flovilmart
Copy link
Contributor

It’s not just about allowing dot notation. Then you need atomic updates in bot oh and mongodb, and posssivly all DB adapters. This is a very low hanging fruit,I mean, I your ‘need’ this, why not use mongo directly? Or mongoose? At one point if the parse SDK is simply a transform over the mongodb query language, whst’s The point?

@zartre
Copy link
Author

zartre commented Oct 27, 2018

Actually my intent was that there should be a way to set just specific data (key) that has a change. Say, a user has achievements object: { cats: 10, dogs: 6 }. When cats has an update, there should be a way to just set cats without the need to set the entire achievements object. Or did I miss anything? Very new to Parse.

@flovilmart
Copy link
Contributor

Perhaps you should consider another mechanism. Nesting documents is likely a bad design example, and likely you should use multiple classes and objects

@dplewis
Copy link
Member

dplewis commented Oct 27, 2018

I was updating my MySQL adapter and accidentally added this. Surprised that this didn’t work for Postgres out of the box.

@dplewis
Copy link
Member

dplewis commented Dec 14, 2018

If anybody is interested this functionality already exists.

Pass in ignoreValidation to set options.

set(key, value, { ignoreValidation: true });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants