UNPKG

@datastax/astra-db-ts

Version:
23 lines (22 loc) 866 B
"use strict"; // Copyright Datastax, Inc // SPDX-License-Identifier: Apache-2.0 Object.defineProperty(exports, "__esModule", { value: true }); exports.coalesceUpsertIntoUpdateResult = exports.mkUpdateResult = void 0; const index_js_1 = require("../../../lib/index.js"); const mkUpdateResult = (resp) => ({ modifiedCount: (resp?.status?.modifiedCount ?? 0), matchedCount: (resp?.status?.matchedCount ?? 0), }); exports.mkUpdateResult = mkUpdateResult; const coalesceUpsertIntoUpdateResult = (serdes, commonResult, resp) => (resp.status?.upsertedId) ? { ...commonResult, upsertedId: serdes.deserialize(resp.status.upsertedId, resp, index_js_1.SerDesTarget.InsertedId), upsertedCount: 1, } : { ...commonResult, upsertedCount: 0, }; exports.coalesceUpsertIntoUpdateResult = coalesceUpsertIntoUpdateResult;