Registry / database / query-orm-client

query-orm-client

JSON →
library0.0.8jsnpmunverified

QueryOrmClient is a JavaScript/TypeScript library that provides URL-based ORM-like query construction for building filter, sort, pagination, and field selection parameters in REST API calls. Version 0.0.8 is the latest stable release. It supports rich filter operators (=, !=, >, >=, <, <=, like, in, between), multi-field sorting, select with aliases, and pagination. The library is dependency-free, ships TypeScript type declarations, and works both as an npm module and via a UMD script tag. It automatically encodes URLs and allows optional raw output.

npm install query-orm-client
INSTALL
IMPORT
SIG · QUERY-ORM-CLIENT
Q
query-orm-client
databasejavascriptv0.0.8
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

QueryOrmClient
✓ import QueryOrmClient from 'query-orm-client'
✗ const QueryOrmClient = require('query-orm-client')
Default export; works with both ESM and CJS. For UMD script tag, use global queryOrmClient.
queryOrmClient
✓ // after UMD script: const qoc = new queryOrmClient()
✗ // not available as import
Global when loaded via script tag; not an npm export.
QueryOrmClient type
✓ import type QueryOrmClient from 'query-orm-client'
✗ import { QueryOrmClient } from 'query-orm-client'
Package ships types but type import uses default import syntax with 'type' keyword.

Build a query with where conditions, sorting, field selection, and pagination, then generate the URL query string.

import QueryOrmClient from 'query-orm-client'; const qoc = new QueryOrmClient(); qoc.where('status', 'active') .where('age', '>', 18) .whereIn('tags', ['new', 'hot']) .orderBy('created_at', 'desc') .select(['id', 'name', 'email']) .page(1, 20); const queryString = qoc.toUriQueryString(); console.log(queryString); // Output (approx): filter[status{eq}]=active&filter[age{gt}]=18&filter[tags{in}]=new,hot&order_by=created_at&sorted_by=desc&select=id,name,email&page=1&page_size=20
Debug
Known issues
gotchaMethod chaining is fragile: calling toUriQueryString returns a string, not the QueryOrmClient instance, so further chaining after that will fail.
fix
Always call toUriQueryString last in the chain, or assign intermediate results.
affects: >=0.0.0
gotcharemoveWhere removes ALL conditions for a given field, regardless of how many were added. There is no way to remove a specific condition.
fix
Use removeWhere only when you want to clear all conditions for that field.
affects: >=0.0.0
gotchaOperators 'in' and 'between' expect a single string value (comma-separated) or an array. Passing an array with multiple elements may cause unexpected behavior.
fix
For 'in' and 'between', use a single comma-separated string or an array with exactly one element containing the comma-separated values.
affects: >=0.0.0
gotchatoUriQueryString defaults to encoding the URL. Passing false outputs raw string without encoding, which may cause issues if special characters are present.
fix
Use toUriQueryString() for encoded, toUriQueryString(false) for raw. Only use raw if you are certain the values are safe.
affects: >=0.0.0
breakingThe package version is 0.0.8 and API may change without major version bump, as semver is not strictly followed for pre-1.0 releases.
fix
Pin to exact version in package.json and test before upgrading.
affects: <1.0.0
Errors
Common errors & fixes
TypeError: queryOrm.where is not a function
Using the global queryOrmClient (via script) but then trying to call methods on a non-existent object, or forgetting to invoke the constructor with new.
fix
Ensure you create an instance: const qoc = new queryOrmClient(); (script) or const qoc = new QueryOrmClient(); (ESM).
Cannot read property 'toUriQueryString' of undefined
Chaining methods incorrectly, e.g., calling toUriQueryString() after a method that returns undefined, or assigning to a variable that is not the instance.
fix
Make sure the chain starts with new QueryOrmClient() and ends with toUriQueryString(). Do not call toUriQueryString mid-chain.
Module not found: Error: Can't resolve 'query-orm-client'
Package is not installed, or the import path is incorrect.
fix
Run 'npm install query-orm-client' and ensure you are using the correct import: import QueryOrmClient from 'query-orm-client'.
Upgrade
Version history
0.0.8latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
query-orm-client — npm install query-orm-client · libregistry