-
-
Notifications
You must be signed in to change notification settings - Fork 555
feat(populate): alias option to store populated data on another param #126
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
const populates = [
{ child: 'uid', root: 'users', keyProp: 'uid' } // keeps key on uid parameter
]
@firebaseConnect(({ auth }) => ([
{ path: 'projects', storeAs: 'myProjects' }
])) It seems that both should be documented more clearly. |
Let me know if this doesn't solve it for you, and I can reopen. |
I'll open another one to ask for |
Right now, I have this in my query: populates: [
{ child: 'uid', root: 'users', keyProp: 'uid' }
] And here is what I have to do with my result object (which is called let {
submission: {
uid,
...
}
} = this.props;
// the weird names are due to `populate` not allowing aliasing the populated object's key
const user = uid;
uid = user.uid; Because Any way to get the naming fixed? |
I misunderstood your original description. If you use That said, the renaming or "childAlias" that you are describing is not yet a feature, but I do like the idea of it. Will most likely be placing on the roadmap for a coming version (still wrapping up |
Thanks! Sounds great! One more thing to consider: Maybe rename |
@Domiii That is a great suggestion for naming fixing clarity. Going to look into it. |
@Domiii Are you currently using v1 or v2? There has been a ton of adoption of v2, so I was planning on moving this feature to there (meaning it will most likely get done sooner too). Any objections? |
Sure! TBH: I'm not sufficiently up2date on recent developments anyway, so I'm not sure what the trade-offs are... Sorry! :) |
Bump. Had a few more people ask for this, both for |
…ore from import/export (it would need to be a dependency) * Fix injectTapEventPlugin warning in material example * Add component utils to material example
* Option for including progress in file upload
* feat(populate): `childAlias` for store results of populate on another parameter - #126 * feat(profile): Firestore support for `updateProfile` method - [issue 25 on redux-firestore](prescottprue/redux-firestore#25) * feat(storage): `progress` option added to `uploadFile` method - #346 * feat(storage): `uploadFile` default metadata written to DB now includes `createdAt` * feat(core): `redux-firestore` is no longer a dependency - managed by library user directly * fix(examples): Material-ui example updates (including moving `injectTapEventPlugin()` to `main.js`)
|
Love the
populate
feature. But it has two short-comings (one causing a much greater issue than the other):populate
path, thus making it impossible (or very bothersome) to get the actual id of the object (because in Firebase, it appears to be common practice to NOT add the id to the actual object). That is a huge issue if you need the ID (which is a very common use-case). Or maybe I overlooked an easy way of obtaining that id?Id
suffix to all id fields in my data, for multiple reasons. So basically I have an object containinguid
, and thenuid
gets replaced with the actual user object (which is NOT an id). I would prefer to be able to add another argument to thepopulates
objects, such as:{ child: 'uid', root: 'users', childAlias: 'user' }
.I'd argue that solving issue (2) more or less involves fixing issue (1), since you actually want to add another property to the resulting object, instead of overriding the
id
property (or replace the originalid
prop with it's object, and then add another prop with theid
, e.g.: theuser
property gets replaced, and a_user_id
property is added, holding the originalid
). Either way, I feel that the solution to issue (1) can easily integrate an aliasing feature <3 <3 <3 :)Hoping that at least issue (1) can be solved! (maybe the API already has a solution to this?) :)
The text was updated successfully, but these errors were encountered: