A QueryBuilderBase is used to create database queries using an API (no string based query language). Building the queries involves calling functions to add conditions for the query. In the end a Query object is build, which then can be used to actually run the query (potentially multiple times). For generated code, you can also use the templated subclass QueryBuilder instead to have type safety at compile time. More...
#include <objectbox.hpp>
Public Member Functions | |
QueryBuilderBase (Store &store, obx_schema_id entityId) | |
QueryBuilderBase (Store &store, const char *entityName) | |
QueryBuilderBase (Store &store, OBX_query_builder *ptr, bool isRoot) | |
Take ownership of an OBX_query_builder. More... | |
QueryBuilderBase (const QueryBuilderBase &)=delete | |
Can't be copied, single owner of C resources is required (e.g. avoid double-free during destruction) More... | |
QueryBuilderBase (QueryBuilderBase &&source) noexcept | |
virtual | ~QueryBuilderBase () |
OBX_query_builder * | cPtr () const |
QueryBuilderBase & | relationCount (obx_schema_id relationEntityId, obx_schema_id relationPropertyId, uint32_t relationCount) |
An object matches, if it has a given number of related objects pointing to it. At this point, there are a couple of limitations (later version may improve on that): 1) 1:N relations only, 2) the complexity is O(n * (relationCount + 1)) and cannot be improved via indexes, 3) The relation count cannot be set as an parameter. More... | |
QueryBuilderBase & | equals (obx_schema_id propertyId, int64_t value) |
QueryBuilderBase & | notEquals (obx_schema_id propertyId, int64_t value) |
QueryBuilderBase & | greaterThan (obx_schema_id propertyId, int64_t value) |
QueryBuilderBase & | lessThan (obx_schema_id propertyId, int64_t value) |
QueryBuilderBase & | equalsString (obx_schema_id propertyId, const char *value, bool caseSensitive=true) |
QueryBuilderBase & | notEqualsString (obx_schema_id propertyId, const char *value, bool caseSensitive=true) |
QueryBuilderBase & | order (obx_schema_id propertyId, uint32_t flags=0) |
Adds an order based on a given property. More... | |
QueryBuilderBase & | with (const QueryCondition &condition) |
Appends given condition/combination of conditions. More... | |
QueryBuilderBase & | nearestNeighborsFloat32 (obx_schema_id vectorPropertyId, const float *queryVector, size_t maxResultCount) |
Performs an approximate nearest neighbor (ANN) search to find objects near to the given query_vector. This requires the vector property to have a HNSW index. More... | |
QueryBase | buildBase () |
Once all conditions have been applied, build the query using this method to actually run it. More... | |
Protected Attributes | |
Store & | store_ |
OBX_query_builder * | cQueryBuilder_ |
const obx_schema_id | entityId_ |
const bool | isRoot_ |
A QueryBuilderBase is used to create database queries using an API (no string based query language). Building the queries involves calling functions to add conditions for the query. In the end a Query object is build, which then can be used to actually run the query (potentially multiple times). For generated code, you can also use the templated subclass QueryBuilder instead to have type safety at compile time.
|
inline |
|
inline |
|
inlineexplicit |
Take ownership of an OBX_query_builder.
*Example:**
QueryBuilder innerQb(obx_qb_link_property(outerQb.cPtr(), linkPropertyId), false)
|
delete |
Can't be copied, single owner of C resources is required (e.g. avoid double-free during destruction)
|
inlinenoexcept |
|
inlinevirtual |
QueryBase obx::QueryBuilderBase::buildBase | ( | ) |
Once all conditions have been applied, build the query using this method to actually run it.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Performs an approximate nearest neighbor (ANN) search to find objects near to the given query_vector. This requires the vector property to have a HNSW index.
vectorPropertyId | the vector property ID of the entity |
queryVector | the query vector; its dimensions should be at least the dimensions of the vector property. |
maxResultCount | maximum number of objects to return by the ANN condition. Hint: it can also be used as the "ef" HNSW parameter to increase the search quality in combination with a query limit. For example, use 100 here with a query limit of 10 to have 10 results that are of potentially better quality than just passing in 10 here (quality/performance tradeoff). |
|
inline |
|
inline |
|
inline |
Adds an order based on a given property.
property | the property used for the order |
flags | combination of OBXOrderFlags |
|
inline |
An object matches, if it has a given number of related objects pointing to it. At this point, there are a couple of limitations (later version may improve on that): 1) 1:N relations only, 2) the complexity is O(n * (relationCount + 1)) and cannot be improved via indexes, 3) The relation count cannot be set as an parameter.
relationEntityId | ID of the entity type the relation comes from. |
relationPropertyId | ID of the property in the related entity type representing the relation. |
relationCount | Number of related object an object must have to match. May be 0 if objects shall be matched that do not have related objects. (Typically low numbers are used for the count.) |
|
inline |
Appends given condition/combination of conditions.
|
protected |
|
protected |
|
protected |
|
protected |