New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

accel-record

Package Overview
Dependencies
Maintainers
0
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

accel-record - npm Package Compare versions

Comparing version 1.10.1 to 1.11.0

8

package.json
{
"name": "accel-record",
"version": "1.10.1",
"version": "1.11.0",
"description": "Accel Record is a type-safe and synchronous ORM for TypeScript. It adopts the Active Record pattern and is heavily influenced by Ruby on Rails' Active Record.",

@@ -45,6 +45,6 @@ "type": "module",

"dependencies": {
"accel-record-core": "^1.10.1",
"accel-record-factory": "^1.10.1",
"prisma-generator-accel-record": "^1.10.1"
"accel-record-core": "^1.11.0",
"accel-record-factory": "^1.11.0",
"prisma-generator-accel-record": "^1.11.0"
}
}

@@ -30,4 +30,5 @@ Language: [English](https://github.com/koyopro/accella/blob/main/packages/accel-record/README.md) | [日本語](https://github.com/koyopro/accella/blob/main/packages/accel-record/README-ja.md)

- [Query Interface](#query-interface)
- [Scopes](#scopes)
- [Flexible Search](#flexible-search)
- [Testing](#testing)
- [Scopes](#scopes)
- [Validation](#validation)

@@ -783,2 +784,53 @@ - [Callbacks](#callbacks)

## Flexible Search
Using the `.search()` method, you can perform object-based flexible searches.
(The interface is inspired by the Ransack gem.)
Search parameters are specified as an object with keys representing the field name and search condition combination strings, and values representing the search values.
You can include associations in the keys.
The search conditions include `eq`, `cont`, `matches`, `lt`, `gte`, `in`, `null`, and more.
In addition, modifiers such as `not`, `or`, `and`, `any`, `all` are also available.
Please refer to the documentation of the search() method for more details.
```ts
import { User } from "./models/index.js";
const search = User.search({
name_eq: "John", // name equals "John"
age_not_null: 1, // age is not null
profile_bio_cont: "foo", // related profile's bio contains "foo"
email_or_name_cont_any: ["bar", "baz"], // email or name contains "bar" or "baz"
});
const users = search.result();
```
Additionally, you can include the names of searchable scopes defined in the `searchableScopes` array as keys in the search parameters.
For example, the `bio_cont` scope defined as follows can be used in the search parameters:
```ts
// src/models/user.ts
import { scope } from "accel-record";
import { ApplicationRecord } from "./applicationRecord.js";
class UserModel extends ApplicationRecord {
@scope
static bio_cont(value: string) {
return this.joins("profile").where({
profile: { bio: { contains: value } },
});
}
static searchableScopes = ["bio_cont"];
}
```
```ts
import { User } from "./models/index.js";
const search = User.search({ bio_cont: "foo" }); // profile's bio contains "foo"
const users = search.result();
```
## Testing

@@ -1294,4 +1346,3 @@

- [accel-record-core] Support for Composite IDs
- [accel-record-core] Expansion of Query Interface
Related: [Accel Record Roadmap](https://github.com/koyopro/accella/issues/1)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc