firestore-admin
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -252,6 +252,6 @@ let DOCUMENT = require('./document.js'); | ||
/** | ||
* Get all documents in this collection. | ||
* @returns {Promise<Array>} Returns a Promise that resolves with a list of DocumentReference objects. | ||
* Get all document snapshots in this collection. | ||
* @returns {Promise<Array>} Returns a Promise that resolves with a list of DocumentSnapshot objects. | ||
*/ | ||
GetDocs() { | ||
GetDocSnapshots() { | ||
return new Promise((resolve, reject) => { | ||
@@ -264,5 +264,5 @@ this.collection_.get().then(snapshot => { | ||
let docs = snapshot.docs.map(x => x.ref); | ||
resolve(docs); | ||
}).catch(error => reject(`Failed to get docs: ${error}.`)); | ||
let docSnapshots = snapshot.docs; | ||
resolve(docSnapshots); | ||
}).catch(error => reject(`Failed to get doc snapshots: ${error}.`)); | ||
}); | ||
@@ -272,10 +272,10 @@ } | ||
/** | ||
* Get document by name. | ||
* Get document snapshot by name. | ||
* @param {string} name | ||
* @returns {Promise<object>} Returns a Promise that resolves with a Document object. | ||
* @returns {Promise<object>} Returns a Promise that resolves with a DocumentSnapshot object. | ||
*/ | ||
GetDoc(name) { | ||
GetDocSnapshot(name) { | ||
return new Promise((resolve, reject) => { | ||
this.GetDocs().then(docs => { | ||
if (!docs || docs.length == 0) { | ||
this.GetDocSnapshots().then(docSnapshots => { | ||
if (!docSnapshots || docSnapshots.length == 0) { | ||
resolve(null); | ||
@@ -285,3 +285,3 @@ return; | ||
let filteredDocs = docs.filter(x => x.id == name); | ||
let filteredDocs = docSnapshots.filter(x => x.id == name); | ||
if (!filteredDocs || filteredDocs.length == 0) { | ||
@@ -293,3 +293,3 @@ resolve(null); | ||
resolve(filteredDocs[0]); | ||
}).catch(error => reject(`Failed to get doc by name: ${error}.`)); | ||
}).catch(error => reject(`Failed to get doc snapshot by name: ${error}.`)); | ||
}); | ||
@@ -296,0 +296,0 @@ } |
@@ -140,3 +140,3 @@ let FIREBASE_ADMIN = require('firebase-admin'); | ||
* Get all collections. | ||
* @returns {Promise<Array>} Returns a Promise that resolves with a list of collections. | ||
* @returns {Promise<Array>} Returns a Promise that resolves with a list of CollectionReference objects. | ||
*/ | ||
@@ -154,3 +154,3 @@ GetCollections() { | ||
* @param {string} collectionName | ||
* @returns {Promise<object>} Returns a Promise that resolves with the desired collection (or null iof it doesn't exist). | ||
* @returns {Promise<object>} Returns a Promise that resolves with the desired CollectionReference (or null iof it doesn't exist). | ||
*/ | ||
@@ -157,0 +157,0 @@ GetCollection(collectionName) { |
@@ -86,7 +86,7 @@ let FIREBASE_ADMIN = require('firebase-admin'); | ||
/** | ||
* Retrieve all documents in a collection. | ||
* Retrieve all document snapshots in a collection. | ||
* @param {string} collectionName | ||
* @returns {Promise<Array>} Returns a Promise that resolves with a list of Documents. | ||
* @returns {Promise<Array>} Returns a Promise that resolves with a list of DocumentSnapshot objects. | ||
*/ | ||
GetDocs(collectionName) { | ||
GetDocSnapshots(collectionName) { | ||
return new Promise((resolve, reject) => { | ||
@@ -99,6 +99,6 @@ this.db_.collection(collectionName).get().then(snapshot => { | ||
let docs = snapshot.docs.map(x => x.ref); // Turn document snapshots into document references. | ||
let docSnapshots = snapshot.docs; | ||
resolve(docs); | ||
}).catch(error => reject(`Failed to get documents: ${error}.`)); | ||
resolve(docSnapshots); | ||
}).catch(error => reject(`Failed to get document snapshots: ${error}.`)); | ||
}); | ||
@@ -108,3 +108,3 @@ } | ||
/** | ||
* Retrieve a single Document from the specified collection. | ||
* Retrieve a single DocumentSnapshot from the specified collection. | ||
* @param {string} collectionName | ||
@@ -114,3 +114,3 @@ * @param {string} docName Alias to identify the data. | ||
*/ | ||
GetDoc(collectionName, docName) { | ||
GetDocSnapshot(collectionName, docName) { | ||
return new Promise((resolve, reject) => { | ||
@@ -124,5 +124,5 @@ | ||
let docs = snapshot.docs.map(x => x.ref); // Turn document snapshots into document references. | ||
let docSnapshots = snapshot.docs; | ||
let filteredDocs = docs.filter(x => x.id == docName); | ||
let filteredDocs = docSnapshots.filter(x => x.id == docName); | ||
if (!filteredDocs || filteredDocs.length == 0) { | ||
@@ -134,3 +134,3 @@ resolve(null); | ||
resolve(filteredDocs[0]); | ||
}).catch(error => reject(`Failed to get document: ${error}.`)); | ||
}).catch(error => reject(`Failed to get document snapshot: ${error}.`)); | ||
}); | ||
@@ -137,0 +137,0 @@ } |
{ | ||
"name": "firestore-admin", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Firestore admin database API", | ||
@@ -5,0 +5,0 @@ "main": "api.js", |
@@ -17,3 +17,3 @@ class QuerySnapshot { | ||
/** | ||
* @returns {Array<object>} Returns an array of all the documents (as DocumentReference objects) in this QuerySnapshot. | ||
* @returns {Array<object>} Returns an array of all the DocumentSnapshot objects in this QuerySnapshot. | ||
*/ | ||
@@ -20,0 +20,0 @@ Docs() { |
45775