@andrew_l/mongo-pagination 0.3.22 → 0.4.0
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/dist/_chunks/QueryPaginator.d.mts +198 -0
- package/dist/_chunks/QueryPaginator.d.mts.map +1 -0
- package/dist/_chunks/withMongoosePagination.mjs +489 -0
- package/dist/_chunks/withMongoosePagination.mjs.map +1 -0
- package/dist/index.d.mts +13 -14
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +36 -46
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose-7.d.mts +9 -12
- package/dist/mongoose-7.d.mts.map +1 -0
- package/dist/mongoose-7.mjs +14 -27
- package/dist/mongoose-7.mjs.map +1 -1
- package/dist/mongoose-8.d.mts +9 -12
- package/dist/mongoose-8.d.mts.map +1 -0
- package/dist/mongoose-8.mjs +14 -27
- package/dist/mongoose-8.mjs.map +1 -1
- package/package.json +14 -11
- package/dist/index.cjs +0 -56
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -150
- package/dist/index.d.ts +0 -150
- package/dist/mongoose-7.cjs +0 -36
- package/dist/mongoose-7.cjs.map +0 -1
- package/dist/mongoose-7.d.cts +0 -16
- package/dist/mongoose-7.d.ts +0 -16
- package/dist/mongoose-8.cjs +0 -36
- package/dist/mongoose-8.cjs.map +0 -1
- package/dist/mongoose-8.d.cts +0 -16
- package/dist/mongoose-8.d.ts +0 -16
- package/dist/shared/mongo-pagination.Ckfb2fG8.mjs +0 -663
- package/dist/shared/mongo-pagination.Ckfb2fG8.mjs.map +0 -1
- package/dist/shared/mongo-pagination.D7Mb8JCq.d.cts +0 -195
- package/dist/shared/mongo-pagination.D7Mb8JCq.d.mts +0 -195
- package/dist/shared/mongo-pagination.D7Mb8JCq.d.ts +0 -195
- package/dist/shared/mongo-pagination.odJCU2tV.cjs +0 -676
- package/dist/shared/mongo-pagination.odJCU2tV.cjs.map +0 -1
package/dist/index.d.cts
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { Q as QueryAdapter, T as Token, a as QueryPaginatorOptions, b as QueryPaginator } from './shared/mongo-pagination.D7Mb8JCq.cjs';
|
|
2
|
-
export { c as QueryPaginatorMeta, d as QueryPaginatorResult, f as TokenOptions, e as createToken, p as parseToken } from './shared/mongo-pagination.D7Mb8JCq.cjs';
|
|
3
|
-
import { Sort, FindCursor } from 'mongodb';
|
|
4
|
-
import { Query } from 'mongoose';
|
|
5
|
-
import 'node:stream';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Creates a range filter based on sorting direction and values.
|
|
9
|
-
*
|
|
10
|
-
* This function generates a range filter to be used in queries, typically for pagination,
|
|
11
|
-
* based on the provided sorting direction (ascending or descending) and the sorting values (field names and values).
|
|
12
|
-
*
|
|
13
|
-
* @param sortDirection - The sorting direction, which could be ascending or descending.
|
|
14
|
-
* @param sortValues - The sorting values, including field names and their respective values for sorting.
|
|
15
|
-
* @returns A range filter object that can be used in MongoDB.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* // Example usage
|
|
19
|
-
* const sortDirection = { age: 1 };
|
|
20
|
-
* const sortValues = { age: 30 };
|
|
21
|
-
* const rangeFilter = createRangeFilter(sortDirection, sortValues);
|
|
22
|
-
* console.log(rangeFilter);
|
|
23
|
-
* // Output: { age: { $gt: 30 } }
|
|
24
|
-
*
|
|
25
|
-
* @group Utils
|
|
26
|
-
*/
|
|
27
|
-
declare function createRangeFilter(sortDirection: Sort, sortValues: Record<string, any>): Record<string, any>;
|
|
28
|
-
/**
|
|
29
|
-
* Merges two MongoDB filters in the most effective way.
|
|
30
|
-
*
|
|
31
|
-
* This function combines two filters, prioritizing the most specific criteria
|
|
32
|
-
* from both and ensuring the merged filter works efficiently for MongoDB queries.
|
|
33
|
-
*
|
|
34
|
-
* @param first - The first MongoDB filter object.
|
|
35
|
-
* @param second - The second MongoDB filter object.
|
|
36
|
-
* @returns The merged MongoDB filter object, combining both filters.
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* // Basic usage:
|
|
40
|
-
* const filter1 = { status: 'active', age: { $gt: 18 } };
|
|
41
|
-
* const filter2 = { age: { $lt: 60 }, country: 'USA' };
|
|
42
|
-
*
|
|
43
|
-
* const mergedFilter = mergeFilters(filter1, filter2);
|
|
44
|
-
* console.log(mergedFilter);
|
|
45
|
-
* // Output: { status: 'active', age: { $gt: 18, $lt: 60 }, country: 'USA' }
|
|
46
|
-
*
|
|
47
|
-
* @group Utils
|
|
48
|
-
*/
|
|
49
|
-
declare function mergeFilters(first: Record<string, any>, second: Record<string, any>): Record<string, any>;
|
|
50
|
-
interface TweakQueryOptions {
|
|
51
|
-
query: QueryAdapter.QueryAdapter;
|
|
52
|
-
paginationFields: string[];
|
|
53
|
-
token?: Token;
|
|
54
|
-
}
|
|
55
|
-
declare function tweakQuery({ paginationFields, token, query, }: TweakQueryOptions): string[];
|
|
56
|
-
|
|
57
|
-
type AnyQuery = Query<any, any>;
|
|
58
|
-
type ExtractDocType<T> = T extends Query<infer X, any> ? X : never;
|
|
59
|
-
/**
|
|
60
|
-
* Enhances a Mongoose query with pagination capabilities.
|
|
61
|
-
*
|
|
62
|
-
* @param query - The Mongoose query to be paginated.
|
|
63
|
-
* @param [options] - Optional configuration for pagination.
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* // Basic usage with a Mongoose query:
|
|
67
|
-
* import { withMongoosePagination } from './pagination';
|
|
68
|
-
* import mongoose from 'mongoose';
|
|
69
|
-
*
|
|
70
|
-
* async function paginateMongooseQuery() {
|
|
71
|
-
* const User = mongoose.model('User', new mongoose.Schema({ name: String, status: String }));
|
|
72
|
-
*
|
|
73
|
-
* const query = User.find({ status: 'active' });
|
|
74
|
-
*
|
|
75
|
-
* const paginator = withMongoosePagination(query, {
|
|
76
|
-
* paginationFields: ['_id'],
|
|
77
|
-
* next: null,
|
|
78
|
-
* });
|
|
79
|
-
*
|
|
80
|
-
* const result = await paginator.exec();
|
|
81
|
-
* console.log(result.items); // Logs the items for the current page
|
|
82
|
-
* console.log(result.metadata); // Logs pagination metadata
|
|
83
|
-
* }
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* // Using custom preQuery and postQuery callbacks:
|
|
87
|
-
* const paginator = withMongoosePagination(query, {
|
|
88
|
-
* preQuery: function () {
|
|
89
|
-
* console.log('Before executing the query');
|
|
90
|
-
* },
|
|
91
|
-
* postQuery: function () {
|
|
92
|
-
* console.log('After executing the query');
|
|
93
|
-
* },
|
|
94
|
-
* });
|
|
95
|
-
*
|
|
96
|
-
* const result = await paginator.exec();
|
|
97
|
-
* console.log(result.items); // Logs items for the current page
|
|
98
|
-
* console.log(result.metadata); // Logs pagination metadata
|
|
99
|
-
*
|
|
100
|
-
* @group Main
|
|
101
|
-
*/
|
|
102
|
-
declare function withMongoosePagination<T extends AnyQuery>(query: T, options?: QueryPaginatorOptions): QueryPaginator<ExtractDocType<T>>;
|
|
103
|
-
|
|
104
|
-
type ExtractSchema<T> = T extends FindCursor<infer X> ? X : never;
|
|
105
|
-
/**
|
|
106
|
-
* Enhances a MongoDB `FindCursor` with pagination capabilities.
|
|
107
|
-
*
|
|
108
|
-
* @param cursor - The MongoDB cursor to be paginated.
|
|
109
|
-
* @param [options] - Optional configuration for pagination.
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* // Basic usage with a MongoDB cursor:
|
|
113
|
-
* import { MongoClient } from 'mongodb';
|
|
114
|
-
*
|
|
115
|
-
* async function paginateCollection() {
|
|
116
|
-
* const client = new MongoClient('mongodb://localhost:27017');
|
|
117
|
-
* await client.connect();
|
|
118
|
-
*
|
|
119
|
-
* const db = client.db('exampleDb');
|
|
120
|
-
* const collection = db.collection('exampleCollection');
|
|
121
|
-
*
|
|
122
|
-
* const cursor = collection.find({ status: 'active' });
|
|
123
|
-
*
|
|
124
|
-
* const paginator = withMongoPagination(cursor, {
|
|
125
|
-
* paginationFields: ['_id'],
|
|
126
|
-
* next: null,
|
|
127
|
-
* });
|
|
128
|
-
*
|
|
129
|
-
* const result = await paginator.exec();
|
|
130
|
-
* console.log(result.items); // Logs the items for the current page
|
|
131
|
-
* console.log(result.metadata); // Logs pagination metadata
|
|
132
|
-
* }
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* @example
|
|
136
|
-
* // Using a custom preQuery callback:
|
|
137
|
-
* const paginator = withMongoPagination(cursor, {
|
|
138
|
-
* preQuery: function () {
|
|
139
|
-
* console.log('Executing query...');
|
|
140
|
-
* },
|
|
141
|
-
* });
|
|
142
|
-
*
|
|
143
|
-
* const result = await paginator.exec();
|
|
144
|
-
* console.log(result.items);
|
|
145
|
-
*
|
|
146
|
-
* @group Main
|
|
147
|
-
*/
|
|
148
|
-
declare function withMongoPagination<T extends FindCursor>(cursor: T, options?: QueryPaginatorOptions): QueryPaginator<ExtractSchema<T>>;
|
|
149
|
-
|
|
150
|
-
export { QueryPaginatorOptions, createRangeFilter, mergeFilters, tweakQuery, withMongoPagination, withMongoosePagination };
|
package/dist/index.d.ts
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { Q as QueryAdapter, T as Token, a as QueryPaginatorOptions, b as QueryPaginator } from './shared/mongo-pagination.D7Mb8JCq.js';
|
|
2
|
-
export { c as QueryPaginatorMeta, d as QueryPaginatorResult, f as TokenOptions, e as createToken, p as parseToken } from './shared/mongo-pagination.D7Mb8JCq.js';
|
|
3
|
-
import { Sort, FindCursor } from 'mongodb';
|
|
4
|
-
import { Query } from 'mongoose';
|
|
5
|
-
import 'node:stream';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Creates a range filter based on sorting direction and values.
|
|
9
|
-
*
|
|
10
|
-
* This function generates a range filter to be used in queries, typically for pagination,
|
|
11
|
-
* based on the provided sorting direction (ascending or descending) and the sorting values (field names and values).
|
|
12
|
-
*
|
|
13
|
-
* @param sortDirection - The sorting direction, which could be ascending or descending.
|
|
14
|
-
* @param sortValues - The sorting values, including field names and their respective values for sorting.
|
|
15
|
-
* @returns A range filter object that can be used in MongoDB.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* // Example usage
|
|
19
|
-
* const sortDirection = { age: 1 };
|
|
20
|
-
* const sortValues = { age: 30 };
|
|
21
|
-
* const rangeFilter = createRangeFilter(sortDirection, sortValues);
|
|
22
|
-
* console.log(rangeFilter);
|
|
23
|
-
* // Output: { age: { $gt: 30 } }
|
|
24
|
-
*
|
|
25
|
-
* @group Utils
|
|
26
|
-
*/
|
|
27
|
-
declare function createRangeFilter(sortDirection: Sort, sortValues: Record<string, any>): Record<string, any>;
|
|
28
|
-
/**
|
|
29
|
-
* Merges two MongoDB filters in the most effective way.
|
|
30
|
-
*
|
|
31
|
-
* This function combines two filters, prioritizing the most specific criteria
|
|
32
|
-
* from both and ensuring the merged filter works efficiently for MongoDB queries.
|
|
33
|
-
*
|
|
34
|
-
* @param first - The first MongoDB filter object.
|
|
35
|
-
* @param second - The second MongoDB filter object.
|
|
36
|
-
* @returns The merged MongoDB filter object, combining both filters.
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* // Basic usage:
|
|
40
|
-
* const filter1 = { status: 'active', age: { $gt: 18 } };
|
|
41
|
-
* const filter2 = { age: { $lt: 60 }, country: 'USA' };
|
|
42
|
-
*
|
|
43
|
-
* const mergedFilter = mergeFilters(filter1, filter2);
|
|
44
|
-
* console.log(mergedFilter);
|
|
45
|
-
* // Output: { status: 'active', age: { $gt: 18, $lt: 60 }, country: 'USA' }
|
|
46
|
-
*
|
|
47
|
-
* @group Utils
|
|
48
|
-
*/
|
|
49
|
-
declare function mergeFilters(first: Record<string, any>, second: Record<string, any>): Record<string, any>;
|
|
50
|
-
interface TweakQueryOptions {
|
|
51
|
-
query: QueryAdapter.QueryAdapter;
|
|
52
|
-
paginationFields: string[];
|
|
53
|
-
token?: Token;
|
|
54
|
-
}
|
|
55
|
-
declare function tweakQuery({ paginationFields, token, query, }: TweakQueryOptions): string[];
|
|
56
|
-
|
|
57
|
-
type AnyQuery = Query<any, any>;
|
|
58
|
-
type ExtractDocType<T> = T extends Query<infer X, any> ? X : never;
|
|
59
|
-
/**
|
|
60
|
-
* Enhances a Mongoose query with pagination capabilities.
|
|
61
|
-
*
|
|
62
|
-
* @param query - The Mongoose query to be paginated.
|
|
63
|
-
* @param [options] - Optional configuration for pagination.
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* // Basic usage with a Mongoose query:
|
|
67
|
-
* import { withMongoosePagination } from './pagination';
|
|
68
|
-
* import mongoose from 'mongoose';
|
|
69
|
-
*
|
|
70
|
-
* async function paginateMongooseQuery() {
|
|
71
|
-
* const User = mongoose.model('User', new mongoose.Schema({ name: String, status: String }));
|
|
72
|
-
*
|
|
73
|
-
* const query = User.find({ status: 'active' });
|
|
74
|
-
*
|
|
75
|
-
* const paginator = withMongoosePagination(query, {
|
|
76
|
-
* paginationFields: ['_id'],
|
|
77
|
-
* next: null,
|
|
78
|
-
* });
|
|
79
|
-
*
|
|
80
|
-
* const result = await paginator.exec();
|
|
81
|
-
* console.log(result.items); // Logs the items for the current page
|
|
82
|
-
* console.log(result.metadata); // Logs pagination metadata
|
|
83
|
-
* }
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* // Using custom preQuery and postQuery callbacks:
|
|
87
|
-
* const paginator = withMongoosePagination(query, {
|
|
88
|
-
* preQuery: function () {
|
|
89
|
-
* console.log('Before executing the query');
|
|
90
|
-
* },
|
|
91
|
-
* postQuery: function () {
|
|
92
|
-
* console.log('After executing the query');
|
|
93
|
-
* },
|
|
94
|
-
* });
|
|
95
|
-
*
|
|
96
|
-
* const result = await paginator.exec();
|
|
97
|
-
* console.log(result.items); // Logs items for the current page
|
|
98
|
-
* console.log(result.metadata); // Logs pagination metadata
|
|
99
|
-
*
|
|
100
|
-
* @group Main
|
|
101
|
-
*/
|
|
102
|
-
declare function withMongoosePagination<T extends AnyQuery>(query: T, options?: QueryPaginatorOptions): QueryPaginator<ExtractDocType<T>>;
|
|
103
|
-
|
|
104
|
-
type ExtractSchema<T> = T extends FindCursor<infer X> ? X : never;
|
|
105
|
-
/**
|
|
106
|
-
* Enhances a MongoDB `FindCursor` with pagination capabilities.
|
|
107
|
-
*
|
|
108
|
-
* @param cursor - The MongoDB cursor to be paginated.
|
|
109
|
-
* @param [options] - Optional configuration for pagination.
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* // Basic usage with a MongoDB cursor:
|
|
113
|
-
* import { MongoClient } from 'mongodb';
|
|
114
|
-
*
|
|
115
|
-
* async function paginateCollection() {
|
|
116
|
-
* const client = new MongoClient('mongodb://localhost:27017');
|
|
117
|
-
* await client.connect();
|
|
118
|
-
*
|
|
119
|
-
* const db = client.db('exampleDb');
|
|
120
|
-
* const collection = db.collection('exampleCollection');
|
|
121
|
-
*
|
|
122
|
-
* const cursor = collection.find({ status: 'active' });
|
|
123
|
-
*
|
|
124
|
-
* const paginator = withMongoPagination(cursor, {
|
|
125
|
-
* paginationFields: ['_id'],
|
|
126
|
-
* next: null,
|
|
127
|
-
* });
|
|
128
|
-
*
|
|
129
|
-
* const result = await paginator.exec();
|
|
130
|
-
* console.log(result.items); // Logs the items for the current page
|
|
131
|
-
* console.log(result.metadata); // Logs pagination metadata
|
|
132
|
-
* }
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* @example
|
|
136
|
-
* // Using a custom preQuery callback:
|
|
137
|
-
* const paginator = withMongoPagination(cursor, {
|
|
138
|
-
* preQuery: function () {
|
|
139
|
-
* console.log('Executing query...');
|
|
140
|
-
* },
|
|
141
|
-
* });
|
|
142
|
-
*
|
|
143
|
-
* const result = await paginator.exec();
|
|
144
|
-
* console.log(result.items);
|
|
145
|
-
*
|
|
146
|
-
* @group Main
|
|
147
|
-
*/
|
|
148
|
-
declare function withMongoPagination<T extends FindCursor>(cursor: T, options?: QueryPaginatorOptions): QueryPaginator<ExtractSchema<T>>;
|
|
149
|
-
|
|
150
|
-
export { QueryPaginatorOptions, createRangeFilter, mergeFilters, tweakQuery, withMongoPagination, withMongoosePagination };
|
package/dist/mongoose-7.cjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const withMongoosePagination = require('./shared/mongo-pagination.odJCU2tV.cjs');
|
|
4
|
-
require('@andrew_l/toolkit');
|
|
5
|
-
require('kareem');
|
|
6
|
-
require('mongodb');
|
|
7
|
-
require('@andrew_l/tl-pack');
|
|
8
|
-
require('debug');
|
|
9
|
-
require('node:stream');
|
|
10
|
-
|
|
11
|
-
function setupPlugin(mongoose) {
|
|
12
|
-
const Query = mongoose.Query;
|
|
13
|
-
Query.prototype.paginator = paginator;
|
|
14
|
-
Query.prototype.paginatorNext = paginatorNext;
|
|
15
|
-
}
|
|
16
|
-
function paginator(options = {}) {
|
|
17
|
-
const query = this;
|
|
18
|
-
if (arguments.length === 0 && query._paginator) {
|
|
19
|
-
return query._paginator;
|
|
20
|
-
}
|
|
21
|
-
query._paginator = withMongoosePagination.withMongoosePagination(query, options);
|
|
22
|
-
return query._paginator;
|
|
23
|
-
}
|
|
24
|
-
function paginatorNext(nextToken) {
|
|
25
|
-
const query = this;
|
|
26
|
-
if (arguments.length === 0 && query._paginator) {
|
|
27
|
-
return query._paginator;
|
|
28
|
-
}
|
|
29
|
-
query._paginator = withMongoosePagination.withMongoosePagination(query, {
|
|
30
|
-
next: nextToken
|
|
31
|
-
});
|
|
32
|
-
return query._paginator;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
module.exports = setupPlugin;
|
|
36
|
-
//# sourceMappingURL=mongoose-7.cjs.map
|
package/dist/mongoose-7.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mongoose-7.cjs","sources":["../src/mongoose-7.ts"],"sourcesContent":["import type { Query } from 'mongoose';\nimport type { QueryPaginator, QueryPaginatorOptions } from './QueryPaginator';\nimport { withMongoosePagination } from './withMongoosePagination';\n\ntype MongooseQuery = Query<any, any> & {\n /** @internal */\n _paginator?: QueryPaginator;\n};\n\nexport default function setupPlugin(mongoose: any) {\n const Query = mongoose.Query;\n\n Query.prototype.paginator = paginator;\n Query.prototype.paginatorNext = paginatorNext;\n}\n\nfunction paginator(this: MongooseQuery, options: QueryPaginatorOptions = {}) {\n const query = this;\n\n if (arguments.length === 0 && query._paginator) {\n return query._paginator;\n }\n\n query._paginator = withMongoosePagination(query, options);\n\n return query._paginator;\n}\n\nfunction paginatorNext(this: MongooseQuery, nextToken: string) {\n const query = this;\n\n if (arguments.length === 0 && query._paginator) {\n return query._paginator;\n }\n\n query._paginator = withMongoosePagination(query, {\n next: nextToken,\n });\n\n return query._paginator;\n}\n\ndeclare module 'mongoose' {\n /**\n * Patch original mongoose types\n */\n // @ts-expect-error\n interface Query<ResultType, DocType, THelpers = {}, RawDocType = DocType> {\n paginator(options?: QueryPaginatorOptions): QueryPaginator<ResultType>;\n paginatorNext(nextToken: string): QueryPaginator<ResultType>;\n }\n}\n"],"names":["withMongoosePagination"],"mappings":";;;;;;;;;;AASA,SAAwB,YAAY,QAAA,EAAe;AACjD,EAAA,MAAM,QAAQ,QAAA,CAAS,KAAA;AAEvB,EAAA,KAAA,CAAM,UAAU,SAAA,GAAY,SAAA;AAC5B,EAAA,KAAA,CAAM,UAAU,aAAA,GAAgB,aAAA;AAClC;AAEA,SAAS,SAAA,CAA+B,OAAA,GAAiC,EAAC,EAAG;AAC3E,EAAA,MAAM,KAAA,GAAQ,IAAA;AAEd,EAAA,IAAI,SAAA,CAAU,MAAA,KAAW,CAAA,IAAK,KAAA,CAAM,UAAA,EAAY;AAC9C,IAAA,OAAO,KAAA,CAAM,UAAA;AAAA,EACf;AAEA,EAAA,KAAA,CAAM,UAAA,GAAaA,6CAAA,CAAuB,KAAA,EAAO,OAAO,CAAA;AAExD,EAAA,OAAO,KAAA,CAAM,UAAA;AACf;AAEA,SAAS,cAAmC,SAAA,EAAmB;AAC7D,EAAA,MAAM,KAAA,GAAQ,IAAA;AAEd,EAAA,IAAI,SAAA,CAAU,MAAA,KAAW,CAAA,IAAK,KAAA,CAAM,UAAA,EAAY;AAC9C,IAAA,OAAO,KAAA,CAAM,UAAA;AAAA,EACf;AAEA,EAAA,KAAA,CAAM,UAAA,GAAaA,8CAAuB,KAAA,EAAO;AAAA,IAC/C,IAAA,EAAM;AAAA,GACP,CAAA;AAED,EAAA,OAAO,KAAA,CAAM,UAAA;AACf;;;;"}
|
package/dist/mongoose-7.d.cts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { a as QueryPaginatorOptions, b as QueryPaginator } from './shared/mongo-pagination.D7Mb8JCq.cjs';
|
|
2
|
-
import 'node:stream';
|
|
3
|
-
import 'mongodb';
|
|
4
|
-
|
|
5
|
-
declare function setupPlugin(mongoose: any): void;
|
|
6
|
-
declare module 'mongoose' {
|
|
7
|
-
/**
|
|
8
|
-
* Patch original mongoose types
|
|
9
|
-
*/
|
|
10
|
-
interface Query<ResultType, DocType, THelpers = {}, RawDocType = DocType> {
|
|
11
|
-
paginator(options?: QueryPaginatorOptions): QueryPaginator<ResultType>;
|
|
12
|
-
paginatorNext(nextToken: string): QueryPaginator<ResultType>;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export = setupPlugin;
|
package/dist/mongoose-7.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { a as QueryPaginatorOptions, b as QueryPaginator } from './shared/mongo-pagination.D7Mb8JCq.js';
|
|
2
|
-
import 'node:stream';
|
|
3
|
-
import 'mongodb';
|
|
4
|
-
|
|
5
|
-
declare function setupPlugin(mongoose: any): void;
|
|
6
|
-
declare module 'mongoose' {
|
|
7
|
-
/**
|
|
8
|
-
* Patch original mongoose types
|
|
9
|
-
*/
|
|
10
|
-
interface Query<ResultType, DocType, THelpers = {}, RawDocType = DocType> {
|
|
11
|
-
paginator(options?: QueryPaginatorOptions): QueryPaginator<ResultType>;
|
|
12
|
-
paginatorNext(nextToken: string): QueryPaginator<ResultType>;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export = setupPlugin;
|
package/dist/mongoose-8.cjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const withMongoosePagination = require('./shared/mongo-pagination.odJCU2tV.cjs');
|
|
4
|
-
require('@andrew_l/toolkit');
|
|
5
|
-
require('kareem');
|
|
6
|
-
require('mongodb');
|
|
7
|
-
require('@andrew_l/tl-pack');
|
|
8
|
-
require('debug');
|
|
9
|
-
require('node:stream');
|
|
10
|
-
|
|
11
|
-
function setupPlugin(mongoose) {
|
|
12
|
-
const Query = mongoose.Query;
|
|
13
|
-
Query.prototype.paginator = paginator;
|
|
14
|
-
Query.prototype.paginatorNext = paginatorNext;
|
|
15
|
-
}
|
|
16
|
-
function paginator(options = {}) {
|
|
17
|
-
const query = this;
|
|
18
|
-
if (arguments.length === 0 && query._paginator) {
|
|
19
|
-
return query._paginator;
|
|
20
|
-
}
|
|
21
|
-
query._paginator = withMongoosePagination.withMongoosePagination(query, options);
|
|
22
|
-
return query._paginator;
|
|
23
|
-
}
|
|
24
|
-
function paginatorNext(nextToken) {
|
|
25
|
-
const query = this;
|
|
26
|
-
if (arguments.length === 0 && query._paginator) {
|
|
27
|
-
return query._paginator;
|
|
28
|
-
}
|
|
29
|
-
query._paginator = withMongoosePagination.withMongoosePagination(query, {
|
|
30
|
-
next: nextToken
|
|
31
|
-
});
|
|
32
|
-
return query._paginator;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
module.exports = setupPlugin;
|
|
36
|
-
//# sourceMappingURL=mongoose-8.cjs.map
|
package/dist/mongoose-8.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mongoose-8.cjs","sources":["../src/mongoose-8.ts"],"sourcesContent":["import type { Query } from 'mongoose';\nimport type { QueryPaginator, QueryPaginatorOptions } from './QueryPaginator';\nimport { withMongoosePagination } from './withMongoosePagination';\n\ntype MongooseQuery = Query<any, any> & {\n /** @internal */\n _paginator?: QueryPaginator;\n};\n\nexport default function setupPlugin(mongoose: any) {\n const Query = mongoose.Query;\n\n Query.prototype.paginator = paginator;\n Query.prototype.paginatorNext = paginatorNext;\n}\n\nfunction paginator(this: MongooseQuery, options: QueryPaginatorOptions = {}) {\n const query = this;\n\n if (arguments.length === 0 && query._paginator) {\n return query._paginator;\n }\n\n query._paginator = withMongoosePagination(query, options);\n\n return query._paginator;\n}\n\nfunction paginatorNext(this: MongooseQuery, nextToken: string) {\n const query = this;\n\n if (arguments.length === 0 && query._paginator) {\n return query._paginator;\n }\n\n query._paginator = withMongoosePagination(query, {\n next: nextToken,\n });\n\n return query._paginator;\n}\n\ndeclare module 'mongoose' {\n /**\n * Patch original mongoose types for mongoose 8\n */\n // @ts-expect-error\n interface Query<ResultType, DocType> {\n paginator(options?: QueryPaginatorOptions): QueryPaginator<DocType>;\n paginatorNext(nextToken: string): QueryPaginator<DocType>;\n }\n}\n"],"names":["withMongoosePagination"],"mappings":";;;;;;;;;;AASA,SAAwB,YAAY,QAAA,EAAe;AACjD,EAAA,MAAM,QAAQ,QAAA,CAAS,KAAA;AAEvB,EAAA,KAAA,CAAM,UAAU,SAAA,GAAY,SAAA;AAC5B,EAAA,KAAA,CAAM,UAAU,aAAA,GAAgB,aAAA;AAClC;AAEA,SAAS,SAAA,CAA+B,OAAA,GAAiC,EAAC,EAAG;AAC3E,EAAA,MAAM,KAAA,GAAQ,IAAA;AAEd,EAAA,IAAI,SAAA,CAAU,MAAA,KAAW,CAAA,IAAK,KAAA,CAAM,UAAA,EAAY;AAC9C,IAAA,OAAO,KAAA,CAAM,UAAA;AAAA,EACf;AAEA,EAAA,KAAA,CAAM,UAAA,GAAaA,6CAAA,CAAuB,KAAA,EAAO,OAAO,CAAA;AAExD,EAAA,OAAO,KAAA,CAAM,UAAA;AACf;AAEA,SAAS,cAAmC,SAAA,EAAmB;AAC7D,EAAA,MAAM,KAAA,GAAQ,IAAA;AAEd,EAAA,IAAI,SAAA,CAAU,MAAA,KAAW,CAAA,IAAK,KAAA,CAAM,UAAA,EAAY;AAC9C,IAAA,OAAO,KAAA,CAAM,UAAA;AAAA,EACf;AAEA,EAAA,KAAA,CAAM,UAAA,GAAaA,8CAAuB,KAAA,EAAO;AAAA,IAC/C,IAAA,EAAM;AAAA,GACP,CAAA;AAED,EAAA,OAAO,KAAA,CAAM,UAAA;AACf;;;;"}
|
package/dist/mongoose-8.d.cts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { a as QueryPaginatorOptions, b as QueryPaginator } from './shared/mongo-pagination.D7Mb8JCq.cjs';
|
|
2
|
-
import 'node:stream';
|
|
3
|
-
import 'mongodb';
|
|
4
|
-
|
|
5
|
-
declare function setupPlugin(mongoose: any): void;
|
|
6
|
-
declare module 'mongoose' {
|
|
7
|
-
/**
|
|
8
|
-
* Patch original mongoose types for mongoose 8
|
|
9
|
-
*/
|
|
10
|
-
interface Query<ResultType, DocType> {
|
|
11
|
-
paginator(options?: QueryPaginatorOptions): QueryPaginator<DocType>;
|
|
12
|
-
paginatorNext(nextToken: string): QueryPaginator<DocType>;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export = setupPlugin;
|
package/dist/mongoose-8.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { a as QueryPaginatorOptions, b as QueryPaginator } from './shared/mongo-pagination.D7Mb8JCq.js';
|
|
2
|
-
import 'node:stream';
|
|
3
|
-
import 'mongodb';
|
|
4
|
-
|
|
5
|
-
declare function setupPlugin(mongoose: any): void;
|
|
6
|
-
declare module 'mongoose' {
|
|
7
|
-
/**
|
|
8
|
-
* Patch original mongoose types for mongoose 8
|
|
9
|
-
*/
|
|
10
|
-
interface Query<ResultType, DocType> {
|
|
11
|
-
paginator(options?: QueryPaginatorOptions): QueryPaginator<DocType>;
|
|
12
|
-
paginatorNext(nextToken: string): QueryPaginator<DocType>;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export = setupPlugin;
|