cosmos-explorer/src/Common/dataAccess/getPartitionKeyValue.ts
vchske 2f32a676d0
Fixes issue when CRUD with no parition key for all APIs (#1362)
* Fixes issue where empty partition key is treated like nonexistent key for Tables API

* Updated format

* Refactor fix

* Prettier

* Fixes issue when CRUD with no parition key for all APIs

* Format fix

* Refactor to explicitly check for Tables
2022-12-13 11:36:39 -08:00

13 lines
394 B
TypeScript

import { userContext } from "UserContext";
import DocumentId from "../../Explorer/Tree/DocumentId";
export const getPartitionKeyValue = (documentId: DocumentId) => {
if (userContext.apiType === "Tables" && documentId.partitionKeyValue?.length === 0) {
return "";
}
if (documentId.partitionKeyValue?.length === 0) {
return undefined;
}
return documentId.partitionKeyValue;
};