Skip to content

[Firestore] New documents with a persisted ID still creates a new ID #1531

@jdjuan

Description

@jdjuan

1. Version info

Angular: 5.2.0

Firebase: 4.12.0

AngularFire: 5.0.0-rc.6

Node: 8.9.3

Other (e.g. Ionic/Cordova, Node, browser, operating system): Windows 10

2. How to reproduce these conditions

Find all the source code and credentials to a sanitized Firestore project here: StackBlitz

2.1 Steps to set up and reproduce

  1. Create a new Firestore project and bind to an Angular App
  2. Create a reference to a new collection and try to add a persisted ID as specified in the documentation:
const id = this.afs.createId();
const item: Item = { id, name };
this.itemsCollection.add(item);

2.2 Actual Behavior

screenshot-console firebase google com-2018 03 28-06-55-14

2.3 Expected behavior

screenshot-console firebase google com-2018 03 28-06-58-56

Credentials are available in the StackBlitz project

2.4 Solution

The desired behavior can be achieved like this. So either there's a real issue, or the docs are outdated 🤔

const id = db.createId();
const user = { name:'juan' };
users.doc(id).set({ name: 'juan' });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions