Add SimpleStore class. by jmdobry · Pull Request #386 · js-data/js-data

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.