polymerfire icon indicating copy to clipboard operation
polymerfire copied to clipboard

Firestore collection (mixin) items don't have the $key field (used in dom-repeat)

Open danbaechtold opened this issue 7 years ago • 7 comments

Description

The old database and firebase-query added an extra $key field to every item. But the new firestore collection (mixin) does not, but instead uses __id__.

Expected outcome

Either keep it the same in both DBs or point out that __id__ can be used, the same way $key is described: https://www.webcomponents.org/element/firebase/polymerfire/elements/firebase-query

Actual outcome

For now, __id__ has to be used instead of $key (which is fine for me, just need to know).

danbaechtold avatar Nov 08 '17 20:11 danbaechtold

I’m actually considering making a PR to change __id__ to __name__. The latter is used in official firestore docs and implementation.

merlinnot avatar Jan 07 '18 23:01 merlinnot

I'm fine with both, as long as it is shown and documented.

In Firestore it seems to me that both are beeing used (I think ID is more often used, but NAME is used in security rules on resources..):

  • ID: https://firebase.google.com/docs/reference/js/firebase.firestore.DocumentSnapshot
  • ID: https://cloud.google.com/nodejs/docs/reference/firestore/0.10.x/QueryDocumentSnapshot
  • NAME: https://firebase.google.com/docs/firestore/reference/security/

danbaechtold avatar Jan 08 '18 10:01 danbaechtold

id is used as a property on snapshots, while __name__ is used when it refers to a property of an entity itself, in security rules as you've mentioned, but also for ordering etc.

Since we use it as a latter, I'd prefer the __name__.

That would be great to have some feedback from the maintainers :) @tjmonsi @mbleigh

merlinnot avatar Jan 08 '18 10:01 merlinnot

name refers to a fully qualified path including collections, id to the document id. We should keep id.

On Mon, Jan 8, 2018, 2:41 AM Natan Sągol [email protected] wrote:

id is used as a property on snapshots, while name is used when it refers to a property of an entity itself, in security rules as you've mentioned, but also for ordering etc.

Since we use it as a latter, I'd prefer the name.

That would be great to have some feedback from the maintainers :) @tjmonsi https://github.com/tjmonsi @mbleigh https://github.com/mbleigh

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/firebase/polymerfire/issues/306#issuecomment-355932920, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAD_kKOvsvAozeXCSMd6o2MzZHUGqreks5tIfDogaJpZM4QXBM4 .

mbleigh avatar Jan 08 '18 16:01 mbleigh

Ok, good to know.

merlinnot avatar Jan 08 '18 19:01 merlinnot

Sorry guys, just wondering where this firestore mixin is ? I see questions posted about it and discussions but cannot find it in the repo! Cheers

Thkasis avatar Jan 22 '18 22:01 Thkasis

https://github.com/firebase/polymerfire/tree/firestore

It's not in the master yet.

merlinnot avatar Jan 22 '18 22:01 merlinnot