if (id) {
            return docReference(this, type, id).then(doc => doc.set(data).then(() => ({doc, data})));
        } else {
            return rootCollection(this, type).then(collection => {
                const doc = collection.doc();