Как добавить метод пакетной записи Firestore в эту библиотеку скриптов Google Apps - PullRequest
0 голосов
/ 28 февраля 2020

Я хочу написать и отправить запрос на извлечение для метода пакетной записи Firestore в библиотеку FirestoreGoogleAppsScript . Единственная проблема в том, что я понятия не имею, как это сделать. Поэтому мне нужна помощь, чтобы начать. Приведенная выше ссылка представляет собой файл, в который, я думаю, мне следует добавить следующее.

/**
 * Create a batch write with the given fields and an auto-generated ID.
 *
 * @param {string} path the path where the document will be written
 * @param {object} fields the document's fields
 * @return {object} the Document object written to Firestore
 */
this.batch = function (path, fields) {
  const request = new FirestoreRequest_(baseUrl, authToken)
  return createDocument_(path, fields, request)
}

Когда закончите, я бы ожидал вызвать функцию следующим образом.

// Get a new write batch
let batch = db.batch();

// Set the value of 'NYC'
let nycRef = db.collection('cities').doc('NYC');
batch.set(nycRef, {name: 'New York City'});

// Update the population of 'SF'
let sfRef = db.collection('cities').doc('SF');
batch.update(sfRef, {population: 1000000});

// Delete the city 'LA'
let laRef = db.collection('cities').doc('LA');
batch.delete(laRef);

// Commit the batch
return batch.commit().then(function () {
  // ...
});

Является ли это правильным способ приблизиться или я что-то упустил?

...