@@ -315,6 +315,55 @@ class QueryBuilder {
315
315
316
316
OBX_query_builder* cPtr () const { return cQueryBuilder_; }
317
317
318
+ // / Links the (time series) entity type to another entity space using a time point or range defined in the given
319
+ // / linked entity type and properties.
320
+ // / Note: time series functionality (ObjectBox TS) must be available to use this.
321
+ // / @param linkedEntityId Entity type that defines a time point or range
322
+ // / @param beginPropertyId Property of the linked entity defining a time point or the begin of a time range.
323
+ // / Must be a date type (e.g. PropertyType_Date or PropertyType_DateNano).
324
+ // / @param endPropertyId Optional property of the linked entity defining the end of a time range.
325
+ // / Pass zero to only define a time point (begin_property_id).
326
+ // / Must be a date type (e.g. PropertyType_Date or PropertyType_DateNano).
327
+ template <typename ENTITY_LINKED>
328
+ QueryBuilder<ENTITY_LINKED> linkTime (obx_schema_id linkedEntityId, obx_schema_id beginPropertyId,
329
+ obx_schema_id endPropertyId = 0 ) {
330
+ OBX_query_builder* cQB = obx_qb_link_time (cPtr (), linkedEntityId, beginPropertyId, endPropertyId);
331
+ checkPtrOrThrow (cQB, " can't build a query link" );
332
+ return QueryBuilder<ENTITY_LINKED>(store_, cQB);
333
+ }
334
+
335
+ // / Create a link based on a property-relation (many-to-one)
336
+ template <typename ENTITY_LINKED>
337
+ QueryBuilder<ENTITY_LINKED> linkRelationProperty (obx_schema_id relationPropertyId) {
338
+ OBX_query_builder* cQB = obx_qb_link_property (cPtr (), relationPropertyId);
339
+ checkPtrOrThrow (cQB, " can't build a query link" );
340
+ return QueryBuilder<ENTITY_LINKED>(store_, cQB);
341
+ }
342
+
343
+ // / Create a backlink based on a property-relation used in reverse (one-to-many)
344
+ template <typename ENTITY_LINKED>
345
+ QueryBuilder<ENTITY_LINKED> backlinkRelationProperty (obx_schema_id sourceEntityId, obx_schema_id sourcePropertyId) {
346
+ OBX_query_builder* cQB = obx_qb_backlink_property (cPtr (), sourceEntityId, sourcePropertyId);
347
+ checkPtrOrThrow (cQB, " can't build a query link" );
348
+ return QueryBuilder<ENTITY_LINKED>(store_, cQB);
349
+ }
350
+
351
+ // / Create a link based on a standalone relation (many-to-many)
352
+ template <typename ENTITY_LINKED>
353
+ QueryBuilder<ENTITY_LINKED> linkRelationStandalone (obx_schema_id relationId) {
354
+ OBX_query_builder* cQB = obx_qb_link_standalone (cPtr (), relationId);
355
+ checkPtrOrThrow (cQB, " can't build a query link" );
356
+ return QueryBuilder<ENTITY_LINKED>(store_, cQB);
357
+ }
358
+
359
+ // / Create a backlink based on a standalone relation (many-to-many, reverse direction)
360
+ template <typename ENTITY_LINKED>
361
+ QueryBuilder<ENTITY_LINKED> backlinkRelationStandalone (obx_schema_id relationId) {
362
+ OBX_query_builder* cQB = obx_qb_backlink_standalone (cPtr (), relationId);
363
+ checkPtrOrThrow (cQB, " can't build a query link" );
364
+ return QueryBuilder<ENTITY_LINKED>(store_, cQB);
365
+ }
366
+
318
367
Query<EntityT> build ();
319
368
};
320
369
@@ -700,11 +749,36 @@ class Box {
700
749
// / @param relationId ID of a standalone relation, whose source type matches this Box
701
750
// / @param objectId object ID of the relation target type (typically from another Box)
702
751
// / @returns resulting IDs representing objects in this Box
703
- // / @todo improve docs by providing an example with a clear distinction between source and target type
704
752
std::vector<obx_id> standaloneRelBacklinkIds (obx_schema_id relationId, obx_id objectId) {
705
753
return idVectorOrThrow (obx_box_rel_get_backlink_ids (cBox_, relationId, objectId));
706
754
}
707
755
756
+ // / Time series: get the limits (min/max time values) over all objects
757
+ // / @param outMinId pointer to receive an output (may be nullptr)
758
+ // / @param outMinValue pointer to receive an output (may be nullptr)
759
+ // / @param outMaxId pointer to receive an output (may be nullptr)
760
+ // / @param outMaxValue pointer to receive an output (may be nullptr)
761
+ // / @returns true if objects were found (IDs/values are available)
762
+ bool timeSeriesMinMax (obx_id* outMinId, int64_t * outMinValue, obx_id* outMaxId, int64_t * outMaxValue) {
763
+ CursorTx cursorTx (TxMode::READ, store_, EntityBinding::entityId ());
764
+ obx_err err = obx_cursor_ts_min_max (cursorTx.cPtr (), outMinId, outMinValue, outMaxId, outMaxValue);
765
+ if (err == OBX_SUCCESS) return true ;
766
+ if (err == OBX_NOT_FOUND) return false ;
767
+ throwLastError ();
768
+ }
769
+
770
+ // / Time series: get the limits (min/max time values) over objects within the given time range
771
+ // / @returns true if objects were found in the given range (IDs/values are available)
772
+ bool timeSeriesMinMax (int64_t rangeBegin, int64_t rangeEnd, obx_id* outMinId, int64_t * outMinValue,
773
+ obx_id* outMaxId, int64_t * outMaxValue) {
774
+ CursorTx cursorTx (TxMode::READ, store_, EntityBinding::entityId ());
775
+ obx_err err = obx_cursor_ts_min_max_range (cursorTx.cPtr (), rangeBegin, rangeEnd, outMinId, outMinValue,
776
+ outMaxId, outMaxValue);
777
+ if (err == OBX_SUCCESS) return true ;
778
+ if (err == OBX_NOT_FOUND) return false ;
779
+ throwLastError ();
780
+ }
781
+
708
782
private:
709
783
template <typename Vector>
710
784
void putMany (Vector& objects, std::vector<obx_id>* outIds, OBXPutMode mode) {
0 commit comments