npm package diff

Package: @forge/cache

Versions: 1.0.3-next.0 - 1.0.3-next.0-experimental-ab129b0

File: package/out/kvs/query.js

Index: package/out/kvs/query.js
===================================================================
--- package/out/kvs/query.js
+++ package/out/kvs/query.js
@@ -0,0 +1,38 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.KvsQueryBuilder = void 0;
+class KvsQueryBuilder {
+    storageApi;
+    options;
+    constructor(storageApi, options = {}) {
+        this.storageApi = storageApi;
+        this.options = options;
+    }
+    where(property, condition) {
+        this.options.where = [{ property, ...condition }];
+        return this;
+    }
+    cursor(cursor) {
+        this.options.cursor = cursor;
+        return this;
+    }
+    limit(limit) {
+        this.options.limit = limit;
+        return this;
+    }
+    async getOne() {
+        const { results } = await this.limit(1).getMany();
+        if (results && results.length > 0) {
+            return results[0];
+        }
+        return undefined;
+    }
+    getMany() {
+        return this.storageApi.query({
+            limit: this.options.limit,
+            after: this.options.cursor,
+            where: this.options.where
+        });
+    }
+}
+exports.KvsQueryBuilder = KvsQueryBuilder;