Go to your user key, in this case projectKey, which is a variable that you populate somewhere:
private whatEverName(projectKey) { this.projectKey = projectKey; this.af.object('/Projects/' + this.projectKey); }
Call whatEverName (projectKey) in your code somewhere, and you have a custom node key. This tip is valid from July 25, 2017.
I added a bit more to help those trying to create a child of the node, with the one above, with another key as a custom key. This is useful for the association index for this project, such as a list of users working on this project. You may not need this list in the project data, but get it on request. It simplifies data denormalization and has a flatter architecture, the goal of Firebase.
In this case, the node association is called ProjectsMembers, and we write the owner of the project into it. Add other custom nodes in the same way. Pay attention to the backlinks !!! Single quotes will not work. In this case, I set the name of the owner as a link to the keystroke. Easier to read in db.
// Add child node with project key as push key to the association index. this.af.object(`ProjectsMembers/${projectKey}/` + this.ownerKey) .set({ ownerName: this.ownerName });
source share