Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

jmdobry
Copy link
Member

@jmdobry jmdobry commented Aug 6, 2016

This PR proposes to add a SimpleStore class, which is an intermediate class between Container and DataStore. DataStore stores records in instances of LinkedCollection and adds ES5 getters/setters to record classes for automatically linking relations upon insertion into the store as well as when foreign keys change, while SimpleStore just stores records in instances of Collection and does not add the ES5 getters/setters. SimpleStore is perhaps easier to understand, but does not come with the in-memory relation linking features.

This change does not affect DataStore in any way other than it now extends SimpleStore.

For example, let's say company has many member and member belongs to company:

With DataStore:

const company = store.add('company', { id: 1 })
const member = store.add('member', { id: 2, company_id: 1 })

company.members.length // 1
company.members // [{ id: 2, company_id: 1 }]
member.company // { id: 1 }

With SimpleStore:

const company = store.add('company', { id: 1 })
const member = store.add('member', { id: 2, company_id: 1 })

company.members // undefined
member.company // undefined

I welcome any thoughts or feedback.

@jmdobry jmdobry force-pushed the simple-store branch 3 times, most recently from 73dca34 to e51d1c6 Compare August 12, 2016 00:06
@codecov-io
Copy link

Current coverage is 94.71% (diff: 92.00%)

No coverage report found for master at 489620c.

Powered by Codecov. Last update 489620c...7dcbb38

@jmdobry jmdobry merged commit 67bf04b into master Aug 12, 2016
@jmdobry jmdobry deleted the simple-store branch August 12, 2016 00:45
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

Successfully merging this pull request may close these issues.

2 participants