if (id) {
            return docReference(this, type, id).then(ref => ref.set(data).then(() => ({ref, data})));
        } else {
            return rootCollection(this, type).then(ref => ref.push()).then(ref => {
                (snapshot as any)._internalModel.setId(ref.key!);