@datastax/astra-db-ts
Version:
Data API TypeScript client
18 lines (17 loc) • 605 B
JavaScript
// Copyright Datastax, Inc
// SPDX-License-Identifier: Apache-2.0
import { SerDesTarget } from '../../../lib/index.js';
export const mkUpdateResult = (resp) => ({
modifiedCount: (resp?.status?.modifiedCount ?? 0),
matchedCount: (resp?.status?.matchedCount ?? 0),
});
export const coalesceUpsertIntoUpdateResult = (serdes, commonResult, resp) => (resp.status?.upsertedId)
? {
...commonResult,
upsertedId: serdes.deserialize(resp.status.upsertedId, resp, SerDesTarget.InsertedId),
upsertedCount: 1,
}
: {
...commonResult,
upsertedCount: 0,
};