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

Suggestion on getModified() #705

Open
nathanschwarz opened this issue Jun 13, 2019 · 1 comment
Open

Suggestion on getModified() #705

nathanschwarz opened this issue Jun 13, 2019 · 1 comment

Comments

@nathanschwarz
Copy link

nathanschwarz commented Jun 13, 2019

Hi,

I'd like to suggest a modification concerning getModifed().

I think getModified() should return a dictionary (hash map) instead of an Array.
It would then enable us to make decisions based on the modified fields way more easily (calling external APIs, or throwing errors).

for example :

//model (not the complete definition)
{
      name: String,
      firstname: String
}

//setting firstname
doc.set('firstname', 'Arthur')

//getting modified value
const modified = doc.getModified() // { firstname: true, lastname: false }

if (modified.firstname || modified.lastname) {
   console.log("Hello there, I see you've changed your identity 🤓")
}

We could implement it by adding an optional field to the current API :

getModified({ toHashMap: true }) by converting the array to a hash map when necessary.

Or we could replace the current API.

In any case I find it way more practical to have a dictionary (which can be easily converted to an Array with the ES5 Object.keys() API)

@lukejagodzinski
Copy link
Member

lukejagodzinski commented Jun 29, 2019 via email

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

2 participants