Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
O

objection-find

> 编程语言
Open source

Build search queries for objection.js models using HTTP query parameters.

100 stars0 likes0 views
WebsiteGitHub

About

Build search queries for objection.js models using HTTP query parameters.

Topics

  • Introduction
  • Installation
  • Getting started
  • Query parameters
  • Special parameters
  • Additional parameters
  • API documentation

Introduction

Note: since Objection.js (which this library is based on) now requires Node 6.0.0 as the minimum, objection-find will not work on node 5 console.log(persons[0].children); console.log(persons[0].movie); console.log(persons[0].parent.movies);

// Total size of the result if the range wasn't given. console.log(res.data.total); });

bash

In our example `Person` model had a one-to-one relation `parent`, a many-to-many relation `movies` and one-to-many
relation `children`. This example used the `$http` module of [AngularJS](https://angularjs.org/) but you can use
objection-find with anything that can send an HTTP request.

Documentation on the supported query parameters can be found [here](#query-parameters) and API documentation
[here](API.md).

It is recommended to use [query builder](https://www.npmjs.com/package/objection-find-query-builder) for constructing query parameters on the client side.

# Installation

```sh
npm install objection objection-find

Getting started

Easiest way to get started is to use the objection.js example project and copy paste this to the api.js file:

javascript
const findQuery = require('objection-find');

app.get('/persons/search', function (req, res, next) {
  findQuery(Person).build(req.query).then(function (persons) {
    res.send(persons);
  }).catch(next);
});

You also need to run this in the root of the example project to install objection-find:

bash
npm install --save objection-find

Now you can start bombing the /persons/search route. Documentation on the supported query parameters can be found here.

Query parameters

Objection-find understands two kinds of query parameters: filters and special parameters.

Filters

A filter parameter has the following format:

||...:=

…


firstName:eq=Jennifer&parent.age:lt=60&children.firstName:like=%rad%

…

js
const findQuery = require('objection-find');

app.get('/persons', function (req, res, next) {
  const { page, ...query } = req.query;
  
  findQuery(Person)
    .build(query, Person.query().page(page, 12))
    .then(function (persons) {
      res.send(persons);
    })
    .catch(next);
});

Issues· 28 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言