should a collection pass on modifyPayload fns to doc instances?
- Dominant language
- TypeScript
- Stars
- 46
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Description
eg.
this collection for companies:
- adds default fields on inserts
- adds default fields for updates & removes undefined props
```js
export const dbCompanies = magnetar.collection('companies', {
modifyPayloadOn: {
insert: (payload) => addCreatedAtById(defaultsCompany(payload)),
write: (payload) => removeProp(addUpdatedAtBy(payload), undefined),
},
modifyReadResponseOn: { added: defaultsCompany },
})
```
but in case a doc instance is used to insert or update content, these fns won't be run...
```js
dbCompanies.doc('some-id').merge({ newField: undefined })
// or
dbCompanies.doc('some-id').insert({ name: 'howdy Co.,Ltd.' })
```
but there's no easy way with the current syntax to use the same `modifyPayloadOn` fns from the collection.
- The question is: should we by default always use a collection's `modifyPayloadOn` functions if the parent collection has them?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.