
Security News
MCP Steering Committee Launches Official MCP Registry in Preview
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.
@vepler/property-query-builder
Advanced tools
The Propbar Property Query SDK is a TypeScript library that enables the easy construction of complex queries for searching and filtering data. It offers a fluent and intuitive API for building queries with multiple groups and conditions.
The Propbar Property Query SDK is a TypeScript library that enables the easy construction of complex queries for searching and filtering data. It offers a fluent and intuitive API for building queries with multiple groups and conditions.
To install the Propbar Property Query SDK, you can use npm:
npm install @vepler/property-query-builder
OR
yarn add @vepler/property-query-builder
Here's an example demonstrating how to use the Propbar Property Query SDK to construct a query:
This example illustrates how to add groups, add conditions, update conditions, remove conditions, update entire groups, and retrieve the current state of the query.
import { QueryBuilder } from '@vepler/property-query-builder';
const queryBuilder = new QueryBuilder();
// Add a group
const groupId1 = queryBuilder.addGroup('AND');
// Add conditions to the group
queryBuilder.addCondition(groupId1, {
field: 'price',
comparator: 'gt',
value: 250000,
});
queryBuilder.addCondition(groupId1, {
field: 'bedrooms',
comparator: 'eq',
value: 2,
});
// Add another group
const groupId2 = queryBuilder.addGroup('OR');
// Add conditions to the second group
queryBuilder.addCondition(groupId2, {
field: 'price',
comparator: 'gt',
value: 300000,
});
queryBuilder.addCondition(groupId2, {
field: 'bedrooms',
comparator: 'eq',
value: 3,
});
// Update a condition
queryBuilder.updateCondition(groupId1, 0, {
field: 'price',
comparator: 'gte',
value: 200000,
});
// Remove a condition
queryBuilder.removeCondition(groupId2, 1);
// Update an entire group
queryBuilder.updateGroup(groupId2, 'AND', [
{
field: 'price',
comparator: 'lt',
value: 400000,
},
{
field: 'bedrooms',
comparator: 'gte',
value: 2,
},
]);
// Get the current state of the query
const query = queryBuilder.getQuery();
console.log(JSON.stringify(query, null, 2));
To use the Propbar Property Query SDK in your TypeScript project, import the QueryBuilder
class:
import { QueryBuilder } from '@vepler/property-query-builder';
Create an instance of the QueryBuilder
class to begin building your query:
const queryBuilder = new QueryBuilder();
To add a group to the query, use the addGroup method and specify the operator ('AND' or 'OR'):
const groupId = queryBuilder.addGroup('AND');
The addGroup
method returns a generated group ID that you can use to reference the group when adding or modifying conditions.
To add a condition to a group, use the addCondition method and provide the group ID and the condition object:
queryBuilder.addCondition(groupId, {
field: 'price',
comparator: 'gt',
value: 250000,
});
The condition object should have the following properties:
field
: The field to apply the condition on.comparator
: The comparison operator ('eq', 'ne', 'gt', 'gte', 'lt', 'lte', 'in', 'nin', 'contains', 'startswith', 'endswith', or 'regex').value
: The value to compare against (can be a string, number, boolean, or an array of these types).To remove a condition from a group, use the removeCondition
method and provide the group ID and the index of the condition:
queryBuilder.removeCondition(groupId, conditionIndex);
To update a condition within a group, use the updateCondition
method and provide the group ID, the index of the condition, and the updated condition object:
queryBuilder.updateCondition(groupId, conditionIndex, {
field: 'price',
comparator: 'gte',
value: 200000,
});
To update an entire group, use the updateGroup
method and provide the group ID, the operator, and an array of conditions:
queryBuilder.updateGroup(groupId, 'AND', [
{
field: 'price',
comparator: 'lt',
value: 400000,
},
{
field: 'bedrooms',
comparator: 'gte',
value: 2,
},
]);
To remove a group from the query, use the removeGroup
method and provide the group ID:
queryBuilder.removeGroup(groupId);
To obtain the current state of the query, use the getQuery
method:
const query = queryBuilder.getQuery();
The getQuery
method returns the query object that follows the defined schema.
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"query": {
"type": "array",
"items": {
"type": "object",
"properties": {
"operator": {
"type": "string",
"enum": ["AND", "OR"]
},
"groups": {
"type": "array",
"items": {
"type": "object",
"properties": {
"conditions": {
"type": "array",
"items": {
"type": "object",
"properties": {
"field": {
"type": "string"
},
"comparator": {
"type": "string",
"enum": [
"eq",
"ne",
"gt",
"gte",
"lt",
"lte",
"in",
"nin",
"contains",
"startswith",
"endswith",
"regex"
]
},
"value": {
"oneOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "boolean"
},
{
"type": "array",
"items": {
"oneOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "boolean"
}
]
}
}
]
}
},
"required": ["field", "comparator", "value"]
}
}
},
"required": ["conditions"]
}
}
},
"required": ["operator", "groups"]
}
}
},
"required": ["query"]
}
The Propbar Property Query SDK is open-source software licensed under the MIT License.
FAQs
The Propbar Property Query SDK is a TypeScript library that enables the easy construction of complex queries for searching and filtering data. It offers a fluent and intuitive API for building queries with multiple groups and conditions.
The npm package @vepler/property-query-builder receives a total of 95 weekly downloads. As such, @vepler/property-query-builder popularity was classified as not popular.
We found that @vepler/property-query-builder demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.