@taladb/react-native 0.8.2 → 0.8.4

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.
@@ -244,6 +244,7 @@ std::vector<PropNameID> TalaDBHostObject::getPropertyNames(Runtime &rt) {
244
244
  "updateOne", "updateMany",
245
245
  "deleteOne", "deleteMany",
246
246
  "count",
247
+ "aggregate",
247
248
  "createIndex", "dropIndex",
248
249
  "createFtsIndex", "dropFtsIndex",
249
250
  "createVectorIndex", "dropVectorIndex", "upgradeVectorIndex",
@@ -425,6 +426,24 @@ Value TalaDBHostObject::get(Runtime &rt, const PropNameID &propName) {
425
426
  });
426
427
  }
427
428
 
429
+ // ------------------------------------------------------------------
430
+ // aggregate(collection: string, pipeline: object[]): object[]
431
+ // ------------------------------------------------------------------
432
+ if (name == "aggregate") {
433
+ return Function::createFromHostFunction(
434
+ rt, PropNameID::forAscii(rt, "aggregate"), 2,
435
+ [this](Runtime &rt, const Value &, const Value *args, size_t count) -> Value {
436
+ if (count < 2) throw JSError(rt, "aggregate requires 2 arguments");
437
+ auto col = args[0].getString(rt).utf8(rt);
438
+ auto pipelineJson = stringify(rt, args[1]);
439
+ char *result = taladb_aggregate(db_, col.c_str(), pipelineJson.c_str());
440
+ if (!result) throw JSError(rt, "taladb_aggregate failed");
441
+ std::string json(result);
442
+ taladb_free_string(result);
443
+ return parse(rt, json);
444
+ });
445
+ }
446
+
428
447
  // ------------------------------------------------------------------
429
448
  // createIndex / dropIndex / createFtsIndex / dropFtsIndex
430
449
  // ------------------------------------------------------------------
package/cpp/taladb.h CHANGED
@@ -141,6 +141,19 @@ int32_t taladb_count(TalaDbHandle *handle,
141
141
  const char *collection,
142
142
  const char *filter_json);
143
143
 
144
+ /* -------------------------------------------------------------------------
145
+ * Aggregate
146
+ * ---------------------------------------------------------------------- */
147
+
148
+ /**
149
+ * Run an aggregation pipeline. pipeline_json is a JSON array of stages.
150
+ * Returns a JSON array of result documents, or NULL on error.
151
+ * Caller must free with taladb_free_string().
152
+ */
153
+ char *taladb_aggregate(TalaDbHandle *handle,
154
+ const char *collection,
155
+ const char *pipeline_json);
156
+
144
157
  /* -------------------------------------------------------------------------
145
158
  * Index management
146
159
  * ---------------------------------------------------------------------- */
@@ -244,6 +244,7 @@ std::vector<PropNameID> TalaDBHostObject::getPropertyNames(Runtime &rt) {
244
244
  "updateOne", "updateMany",
245
245
  "deleteOne", "deleteMany",
246
246
  "count",
247
+ "aggregate",
247
248
  "createIndex", "dropIndex",
248
249
  "createFtsIndex", "dropFtsIndex",
249
250
  "createVectorIndex", "dropVectorIndex", "upgradeVectorIndex",
@@ -425,6 +426,24 @@ Value TalaDBHostObject::get(Runtime &rt, const PropNameID &propName) {
425
426
  });
426
427
  }
427
428
 
429
+ // ------------------------------------------------------------------
430
+ // aggregate(collection: string, pipeline: object[]): object[]
431
+ // ------------------------------------------------------------------
432
+ if (name == "aggregate") {
433
+ return Function::createFromHostFunction(
434
+ rt, PropNameID::forAscii(rt, "aggregate"), 2,
435
+ [this](Runtime &rt, const Value &, const Value *args, size_t count) -> Value {
436
+ if (count < 2) throw JSError(rt, "aggregate requires 2 arguments");
437
+ auto col = args[0].getString(rt).utf8(rt);
438
+ auto pipelineJson = stringify(rt, args[1]);
439
+ char *result = taladb_aggregate(db_, col.c_str(), pipelineJson.c_str());
440
+ if (!result) throw JSError(rt, "taladb_aggregate failed");
441
+ std::string json(result);
442
+ taladb_free_string(result);
443
+ return parse(rt, json);
444
+ });
445
+ }
446
+
428
447
  // ------------------------------------------------------------------
429
448
  // createIndex / dropIndex / createFtsIndex / dropFtsIndex
430
449
  // ------------------------------------------------------------------
@@ -141,6 +141,19 @@ int32_t taladb_count(TalaDbHandle *handle,
141
141
  const char *collection,
142
142
  const char *filter_json);
143
143
 
144
+ /* -------------------------------------------------------------------------
145
+ * Aggregate
146
+ * ---------------------------------------------------------------------- */
147
+
148
+ /**
149
+ * Run an aggregation pipeline. pipeline_json is a JSON array of stages.
150
+ * Returns a JSON array of result documents, or NULL on error.
151
+ * Caller must free with taladb_free_string().
152
+ */
153
+ char *taladb_aggregate(TalaDbHandle *handle,
154
+ const char *collection,
155
+ const char *pipeline_json);
156
+
144
157
  /* -------------------------------------------------------------------------
145
158
  * Index management
146
159
  * ---------------------------------------------------------------------- */
@@ -244,6 +244,7 @@ std::vector<PropNameID> TalaDBHostObject::getPropertyNames(Runtime &rt) {
244
244
  "updateOne", "updateMany",
245
245
  "deleteOne", "deleteMany",
246
246
  "count",
247
+ "aggregate",
247
248
  "createIndex", "dropIndex",
248
249
  "createFtsIndex", "dropFtsIndex",
249
250
  "createVectorIndex", "dropVectorIndex", "upgradeVectorIndex",
@@ -425,6 +426,24 @@ Value TalaDBHostObject::get(Runtime &rt, const PropNameID &propName) {
425
426
  });
426
427
  }
427
428
 
429
+ // ------------------------------------------------------------------
430
+ // aggregate(collection: string, pipeline: object[]): object[]
431
+ // ------------------------------------------------------------------
432
+ if (name == "aggregate") {
433
+ return Function::createFromHostFunction(
434
+ rt, PropNameID::forAscii(rt, "aggregate"), 2,
435
+ [this](Runtime &rt, const Value &, const Value *args, size_t count) -> Value {
436
+ if (count < 2) throw JSError(rt, "aggregate requires 2 arguments");
437
+ auto col = args[0].getString(rt).utf8(rt);
438
+ auto pipelineJson = stringify(rt, args[1]);
439
+ char *result = taladb_aggregate(db_, col.c_str(), pipelineJson.c_str());
440
+ if (!result) throw JSError(rt, "taladb_aggregate failed");
441
+ std::string json(result);
442
+ taladb_free_string(result);
443
+ return parse(rt, json);
444
+ });
445
+ }
446
+
428
447
  // ------------------------------------------------------------------
429
448
  // createIndex / dropIndex / createFtsIndex / dropFtsIndex
430
449
  // ------------------------------------------------------------------
@@ -141,6 +141,19 @@ int32_t taladb_count(TalaDbHandle *handle,
141
141
  const char *collection,
142
142
  const char *filter_json);
143
143
 
144
+ /* -------------------------------------------------------------------------
145
+ * Aggregate
146
+ * ---------------------------------------------------------------------- */
147
+
148
+ /**
149
+ * Run an aggregation pipeline. pipeline_json is a JSON array of stages.
150
+ * Returns a JSON array of result documents, or NULL on error.
151
+ * Caller must free with taladb_free_string().
152
+ */
153
+ char *taladb_aggregate(TalaDbHandle *handle,
154
+ const char *collection,
155
+ const char *pipeline_json);
156
+
144
157
  /* -------------------------------------------------------------------------
145
158
  * Index management
146
159
  * ---------------------------------------------------------------------- */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taladb/react-native",
3
- "version": "0.8.2",
3
+ "version": "0.8.4",
4
4
  "description": "TalaDB React Native module — document and vector database via JSI HostObject",
5
5
  "main": "src/index",
6
6
  "types": "src/index.tsx",
@@ -24,7 +24,7 @@
24
24
  "repository": {
25
25
  "type": "git",
26
26
  "url": "https://github.com/thinkgrid-labs/taladb.git",
27
- "directory": "packages/taladb-react-native"
27
+ "directory": "packages/bindings/react-native"
28
28
  },
29
29
  "homepage": "https://thinkgrid-labs.github.io/taladb/guide/react-native",
30
30
  "bugs": {