Adding a subcollection
See original GitHub issueDo you want to request a feature or report a bug?
bug
Is it posible to add a subcollection to firestore using redux-firestore? What is the current behavior? when I add a sub document I like the code below:
withHandlers({
startNewProcess: props => () =>
props.firestore.add(Region/${region}/office/${id}
, { name:props.name})
})
I have also tried props.firestore.add({collection:“Region”,doc:region,subcollections[collection:“office”],doc:id}, { name:props.name})
I get the error below:
Cannot read property ‘apply’ of undefined at wrapInDispatch (actions.js:57) at Object.add (firestore.js:52) at Object.add (actions.js:92) at NewProcessForm.jsx:140 at Recompose.esm.js:183 at HTMLUnknownElement.callCallback (react-dom.development.js:100) at Object.invokeGuardedCallbackDev (react-dom.development.js:138) at Object.invokeGuardedCallback (react-dom.development.js:187) at Object.invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:201) at executeDispatch (react-dom.development.js:461) at executeDispatchesInOrder (react-dom.development.js:483) at executeDispatchesAndRelease (react-dom.development.js:581) at executeDispatchesAndReleaseTopLevel (react-dom.development.js:592) at forEachAccumulated (react-dom.development.js:562) at runEventsInBatch (react-dom.development.js:723) at runExtractedEventsInBatch (react-dom.development.js:732) at handleTopLevel (react-dom.development.js:4476) at batchedUpdates$1 (react-dom.development.js:16659) at batchedUpdates (react-dom.development.js:2131) at dispatchEvent (react-dom.development.js:4555) at interactiveUpdates$1 (react-dom.development.js:16714) at interactiveUpdates (react-dom.development.js:2150) at dispatchInteractiveEvent (react-dom.development.js:4532) wrapInDispatch @ actions.js:57 add @ firestore.js:52 (anonymous) @ actions.js:92 (anonymous) @ NewProcessForm.jsx:140 (anonymous) @ Recompose.esm.js:183 callCallback @ react-dom.development.js:100 invokeGuardedCallbackDev @ react-dom.development.js:138 invokeGuardedCallback @ react-dom.development.js:187 invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:201 executeDispatch @ react-dom.development.js:461 executeDispatchesInOrder @ react-dom.development.js:483 executeDispatchesAndRelease @ react-dom.development.js:581 executeDispatchesAndReleaseTopLevel @ react-dom.development.js:592 forEachAccumulated @ react-dom.development.js:562 runEventsInBatch @ react-dom.development.js:723 runExtractedEventsInBatch @ react-dom.development.js:732 handleTopLevel @ react-dom.development.js:4476 batchedUpdates$1 @ react-dom.development.js:16659 batchedUpdates @ react-dom.development.js:2131 dispatchEvent @ react-dom.development.js:4555 interactiveUpdates$1 @ react-dom.development.js:16714 interactiveUpdates @ react-dom.development.js:2150 dispatchInteractiveEvent @ react-dom.development.js:4532
What is the expected behavior? I expect that the data will stored in firestore under the subcollection in the case “office” with the id provided.
Which versions of dependencies, and which browser are affected by this issue? Did this work in previous versions or setups? I am using version 2.
Steps to reproduce and if possible a minimal demo of the problem via codesandbox or similar.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (2 by maintainers)
Top GitHub Comments
I think I got the Markdown correct now. Thanks for the tip!
I got it working by using set like so:
const docRefConfig = { collection:"Region", doc: "someRegion", subcollections: [{ collection:"office", doc: `${id}` }] } props.firestore.set(docRefConfig, { name:props.name })
Thank you very much for you prompt help and tips! Regards, Tebogo.