@amohamud23/notihub 1.1.9 → 1.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +11 -3
- package/dist/index.js +11 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -940,13 +940,21 @@ var Subscription = class _Subscription {
|
|
|
940
940
|
* @returns A promise that resolves to the subscription object or null if not found.
|
|
941
941
|
*/
|
|
942
942
|
static async getSubscriptionBySubscriptionId(subscriptionId) {
|
|
943
|
-
const command = new import_lib_dynamodb7.
|
|
943
|
+
const command = new import_lib_dynamodb7.QueryCommand({
|
|
944
944
|
TableName: _Subscription.TABLE_NAME,
|
|
945
|
-
|
|
945
|
+
IndexName: "SubscriptionIdIndex",
|
|
946
|
+
// Assuming you have a GSI for userId
|
|
947
|
+
KeyConditionExpression: "subscriptionId = :subscriptionId",
|
|
948
|
+
ExpressionAttributeValues: {
|
|
949
|
+
":subscriptionId": subscriptionId
|
|
950
|
+
}
|
|
946
951
|
});
|
|
947
952
|
try {
|
|
948
953
|
const result = await ddbDocClient.send(command);
|
|
949
|
-
|
|
954
|
+
if (!result.Items || result.Items.length === 0) {
|
|
955
|
+
return null;
|
|
956
|
+
}
|
|
957
|
+
return result.Items[0] || null;
|
|
950
958
|
} catch (error) {
|
|
951
959
|
console.error("Error fetching subscription by SubscriptionId:", error);
|
|
952
960
|
throw new Error("Could not fetch subscription by SubscriptionId");
|
package/dist/index.js
CHANGED
|
@@ -933,13 +933,21 @@ var Subscription = class _Subscription {
|
|
|
933
933
|
* @returns A promise that resolves to the subscription object or null if not found.
|
|
934
934
|
*/
|
|
935
935
|
static async getSubscriptionBySubscriptionId(subscriptionId) {
|
|
936
|
-
const command = new
|
|
936
|
+
const command = new QueryCommand6({
|
|
937
937
|
TableName: _Subscription.TABLE_NAME,
|
|
938
|
-
|
|
938
|
+
IndexName: "SubscriptionIdIndex",
|
|
939
|
+
// Assuming you have a GSI for userId
|
|
940
|
+
KeyConditionExpression: "subscriptionId = :subscriptionId",
|
|
941
|
+
ExpressionAttributeValues: {
|
|
942
|
+
":subscriptionId": subscriptionId
|
|
943
|
+
}
|
|
939
944
|
});
|
|
940
945
|
try {
|
|
941
946
|
const result = await ddbDocClient.send(command);
|
|
942
|
-
|
|
947
|
+
if (!result.Items || result.Items.length === 0) {
|
|
948
|
+
return null;
|
|
949
|
+
}
|
|
950
|
+
return result.Items[0] || null;
|
|
943
951
|
} catch (error) {
|
|
944
952
|
console.error("Error fetching subscription by SubscriptionId:", error);
|
|
945
953
|
throw new Error("Could not fetch subscription by SubscriptionId");
|