UNPKG

@mathrunet/masamune

Version:

Manages packages for the server portion (NodeJS) of the Masamune framework.

59 lines 2.14 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.copyDocument = copyDocument; /** * Processes scheduler commands for document copying. * * ドキュメントコピー用のスケジューラーコマンドを処理します。 * * @param params * Private parameters. * * プライベートパラメーター。 * * @param doc * Document data. * * ドキュメントデータ。 * * @param firestoreInstance * Firestore instance. * * Firestoreインスタンス。 * * @returns * Response. All data will be overwritten into the document. * * レスポンス。データがすべてドキュメントに上書きされます。 */ function copyDocument(_a) { return __awaiter(this, arguments, void 0, function* ({ doc, firestoreInstance, params, }) { const path = params["path"]; const paths = path.split("/"); const id = paths[paths.length - 1]; const docData = doc.data(); const docKeys = Object.keys(docData); const update = {}; for (const key of docKeys) { if (key.startsWith("_") || key == "command" || key == "#command" || key == "@uid") { continue; } update[key] = docData[key]; } update["@uid"] = id; yield firestoreInstance.doc(path).set(update, { merge: true }); return {}; }); } //# sourceMappingURL=copy_document.js.map