Vuefire: Rename .key property

Created on 30 Sep 2017  路  5Comments  路  Source: vuejs/vuefire

As simple as it gets, right now .key is hardcoded.

We have some scenarios where being able to rename it would help us a lot. Right now we have to do it after every request / update.

We should take care of it in updates/sets as we do with .key right now.

RTDB feature request

All 5 comments

Do you have a use case where you need to change the .key property?

When I mix firebase data with other origins and I want to join data.
A basic example:
Firebase
{.key: 1, name: 'name'}
Mysql:
{myprimarykey: 1, surname: 'surname'}
If we can get myprimarykey instead of .key, we don't have to make the "rename/translation" everywhere.
Like you could do "SELECT column1 AS key FROM table"

Not as important, but found it:
When libs won't work with dot properties. They allow me to work with "key" prop but not with ".key" props, because they have problems with dots properties and nested properties.

I also ran into this issue when trying to pass a whole firebase object into a subcomponent as a property with v-bind="myItem". I ended up with the following two errors:

[Vue warn]: Error in nextTick: "InvalidCharacterError: Failed to execute 'setAttribute' on 'Element': '.key' is not a valid attribute name."

and

DOMException: Failed to execute 'setAttribute' on 'Element': '.key' is not a valid attribute name.

I was able to work around this by making a computed property that renames the key, but it'd be nice to just be able to specify an alternate key declaratively, and it'd be even nicer if the default didn't use invalid attribute characters.

@zevdg That'll be solved once the key is made non enumerable

I'm closing this in favor of https://github.com/vuejs/vuefire/issues/240

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mkharibalaji picture mkharibalaji  路  3Comments

cairinmichie picture cairinmichie  路  6Comments

calirails picture calirails  路  5Comments

franciscolourenco picture franciscolourenco  路  7Comments

weavermedia picture weavermedia  路  4Comments