qarjs 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,14 +9,12 @@
|
|
|
9
9
|
|
|
10
10
|
MongoDB-style queries for plain JavaScript arrays. Simple, lightweight, and perfect for Next.js, static sites, and JSON data.
|
|
11
11
|
|
|
12
|
-
[](https://www.npmjs.com/package/qar) [](LICENSE) [](https://bundlephobia.com/package/qar)
|
|
13
|
-
|
|
14
12
|
## Why Qar?
|
|
15
13
|
|
|
16
14
|
When you have a JSON file or an array of objects and need to filter, search, or query them with MongoDB-style syntax - without setting up a database.
|
|
17
15
|
|
|
18
16
|
```javascript
|
|
19
|
-
import { Qar } from '
|
|
17
|
+
import { Qar } from 'qarjs';
|
|
20
18
|
|
|
21
19
|
const products = new Qar(productsData);
|
|
22
20
|
|
|
@@ -43,21 +41,21 @@ products.distinct('category'); // => ['electronics', 'clothing', 'books']
|
|
|
43
41
|
## Installation
|
|
44
42
|
|
|
45
43
|
```bash
|
|
46
|
-
npm install
|
|
44
|
+
npm install qarjs
|
|
47
45
|
```
|
|
48
46
|
|
|
49
47
|
```bash
|
|
50
|
-
yarn add
|
|
48
|
+
yarn add qarjs
|
|
51
49
|
```
|
|
52
50
|
|
|
53
51
|
```bash
|
|
54
|
-
pnpm add
|
|
52
|
+
pnpm add qarjs
|
|
55
53
|
```
|
|
56
54
|
|
|
57
55
|
## Quick Start
|
|
58
56
|
|
|
59
57
|
```javascript
|
|
60
|
-
import { Qar } from '
|
|
58
|
+
import { Qar } from 'qarjs';
|
|
61
59
|
|
|
62
60
|
const data = [
|
|
63
61
|
{ _id: 1, name: 'Alice', age: 20, role: 'user' },
|
|
@@ -562,7 +560,7 @@ Perfect for querying JSON data in Next.js applications:
|
|
|
562
560
|
```javascript
|
|
563
561
|
// app/products/page.tsx
|
|
564
562
|
import productsData from '@/data/products.json';
|
|
565
|
-
import { Qar } from '
|
|
563
|
+
import { Qar } from 'qarjs';
|
|
566
564
|
|
|
567
565
|
const products = new Qar(productsData);
|
|
568
566
|
|
|
@@ -587,7 +585,7 @@ export default function ProductsPage({ searchParams }) {
|
|
|
587
585
|
```javascript
|
|
588
586
|
// app/api/search/route.ts
|
|
589
587
|
import data from '@/data/items.json';
|
|
590
|
-
import { Qar } from '
|
|
588
|
+
import { Qar } from 'qarjs';
|
|
591
589
|
|
|
592
590
|
const items = new Qar(data);
|
|
593
591
|
|
|
@@ -609,7 +607,7 @@ export async function GET(request) {
|
|
|
609
607
|
|
|
610
608
|
```javascript
|
|
611
609
|
import blogPosts from './posts.json';
|
|
612
|
-
import { Qar } from '
|
|
610
|
+
import { Qar } from 'qarjs';
|
|
613
611
|
|
|
614
612
|
const posts = new Qar(blogPosts);
|
|
615
613
|
|
|
@@ -734,7 +732,7 @@ const admins = users.find({ role: 'admin' }).toArray();
|
|
|
734
732
|
Full TypeScript support included:
|
|
735
733
|
|
|
736
734
|
```typescript
|
|
737
|
-
import { Qar } from '
|
|
735
|
+
import { Qar } from 'qarjs';
|
|
738
736
|
|
|
739
737
|
interface User {
|
|
740
738
|
id: number;
|