@ewb/mongoose-query 1.0.1 → 1.0.3
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/lib/Query.d.ts +3 -3
- package/lib/Query.js +1 -1
- package/lib/QueryHandler.d.ts +4 -4
- package/lib/QueryHandler.js +5 -5
- package/lib/QueryModel.d.ts +1 -1
- package/lib/QueryModel.js +1 -1
- package/lib/index.d.ts +6 -9
- package/lib/index.js +6 -6
- package/lib/utils/Query.utils.js +1 -1
- package/lib/utils/constants.d.ts +0 -1
- package/lib/utils/constants.js +0 -1
- package/lib/utils/index.d.ts +3 -0
- package/lib/utils/index.js +3 -0
- package/lib/utils/utils.d.ts +1 -1
- package/package.json +1 -1
package/lib/Query.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import mongoose from 'mongoose';
|
|
2
|
-
import { IQueryPopulate } from './QueryModel';
|
|
3
|
-
import { IMongooseQueryOptions } from './utils/Query.utils';
|
|
4
|
-
import { IQueryOptions, MongooseSortSelectValue, QueryType } from './utils/types';
|
|
2
|
+
import { IQueryPopulate } from './QueryModel.js';
|
|
3
|
+
import { IMongooseQueryOptions } from './utils/Query.utils.js';
|
|
4
|
+
import { IQueryOptions, MongooseSortSelectValue, QueryType } from './utils/types.js';
|
|
5
5
|
export declare class Query<R extends object, T extends object = object, Q extends IMongooseQueryOptions = IMongooseQueryOptions> {
|
|
6
6
|
private _root;
|
|
7
7
|
private _rootNext;
|
package/lib/Query.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import mongoSanitize from 'express-mongo-sanitize';
|
|
2
|
-
import { mongooseQueryOptions, mongooseQueryWithOperation, } from './utils/Query.utils';
|
|
2
|
+
import { mongooseQueryOptions, mongooseQueryWithOperation, } from './utils/Query.utils.js';
|
|
3
3
|
export class Query {
|
|
4
4
|
constructor(queries) {
|
|
5
5
|
this._root = null;
|
package/lib/QueryHandler.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import mongoose from 'mongoose';
|
|
2
|
-
import { Query } from './Query';
|
|
3
|
-
import { ModelSearchPopulate, QueryModel } from './QueryModel';
|
|
2
|
+
import { Query } from './Query.js';
|
|
3
|
+
import { ModelSearchPopulate, QueryModel } from './QueryModel.js';
|
|
4
4
|
export interface QueryFindOpts {
|
|
5
5
|
populate?: boolean;
|
|
6
6
|
select?: boolean;
|
|
@@ -25,8 +25,8 @@ export declare class QueryHandler<T extends object> {
|
|
|
25
25
|
deleteOne(filter: mongoose.FilterQuery<T>): Promise<mongoose.mongo.DeleteResult>;
|
|
26
26
|
populate(query: Query<T>, doc: T | T[any], type?: keyof ModelSearchPopulate<T, any>): Promise<void>;
|
|
27
27
|
getPopulates(type: keyof ModelSearchPopulate<T, any>): ModelSearchPopulate<T, keyof T>[];
|
|
28
|
-
updateMany(
|
|
29
|
-
deleteMany(
|
|
28
|
+
updateMany(query: mongoose.FilterQuery<T>, $in: mongoose.Types.ObjectId[], body: Partial<T>): Promise<mongoose.UpdateWriteOpResult>;
|
|
29
|
+
deleteMany(query: mongoose.FilterQuery<T>, $in: mongoose.Types.ObjectId[]): Promise<mongoose.mongo.DeleteResult>;
|
|
30
30
|
subCreate<K extends keyof T>(sub: K, query: Query<T>, body: any): Promise<(T[K] extends [] ? T[K][0] : null) | null>;
|
|
31
31
|
subSearch<K extends keyof T>(sub: K, query: Query<T>, rootQuery: mongoose.FilterQuery<T>): Promise<{
|
|
32
32
|
count: number;
|
package/lib/QueryHandler.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import mongoose from 'mongoose';
|
|
2
|
-
import { toValidTextRegexp, } from './QueryModel';
|
|
2
|
+
import { toValidTextRegexp, } from './QueryModel.js';
|
|
3
3
|
export class QueryHandler {
|
|
4
4
|
constructor(_model, queryModel) {
|
|
5
5
|
this._model = _model;
|
|
@@ -76,11 +76,11 @@ export class QueryHandler {
|
|
|
76
76
|
}
|
|
77
77
|
return populate.filter((x) => x[type] || x.onAll);
|
|
78
78
|
}
|
|
79
|
-
async updateMany(
|
|
80
|
-
return this._model.updateMany({ _id: { $in
|
|
79
|
+
async updateMany(query, $in, body) {
|
|
80
|
+
return this._model.updateMany({ ...query, _id: { $in } }, { $set: body });
|
|
81
81
|
}
|
|
82
|
-
async deleteMany(
|
|
83
|
-
return this._model.deleteMany({ _id: { $in
|
|
82
|
+
async deleteMany(query, $in) {
|
|
83
|
+
return this._model.deleteMany({ ...query, _id: { $in } });
|
|
84
84
|
}
|
|
85
85
|
async subCreate(sub, query, body) {
|
|
86
86
|
if (!('_id' in body)) {
|
package/lib/QueryModel.d.ts
CHANGED
package/lib/QueryModel.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import mongoose from 'mongoose';
|
|
2
|
-
import { DEFAULT_LIMIT } from './utils/constants';
|
|
2
|
+
import { DEFAULT_LIMIT } from './utils/constants.js';
|
|
3
3
|
export const toValidSelectRegexp = (select) => new RegExp(`^${String(select)}(\..|$)`);
|
|
4
4
|
export const toValidSortRegexp = (sort) => new RegExp(`^(\\+|-)?(${String(sort)}|text)$`);
|
|
5
5
|
export const toValidTextRegexp = (str) => typeof str === 'string'
|
package/lib/index.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export
|
|
7
|
-
export { ISearchPaginate } from './utils/utils';
|
|
8
|
-
export { IQueryAddToModelQuery } from './utils/types';
|
|
9
|
-
export { IQueryOptions } from './utils/types';
|
|
1
|
+
export * from './utils/index.js';
|
|
2
|
+
export * from './QueryError.js';
|
|
3
|
+
export * from './Query.js';
|
|
4
|
+
export * from './QueryHandler.js';
|
|
5
|
+
export * from './QueryHistory.js';
|
|
6
|
+
export * from './QueryModel.js';
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export
|
|
1
|
+
export * from './utils/index.js';
|
|
2
|
+
export * from './QueryError.js';
|
|
3
|
+
export * from './Query.js';
|
|
4
|
+
export * from './QueryHandler.js';
|
|
5
|
+
export * from './QueryHistory.js';
|
|
6
|
+
export * from './QueryModel.js';
|
package/lib/utils/Query.utils.js
CHANGED
package/lib/utils/constants.d.ts
CHANGED
package/lib/utils/constants.js
CHANGED
package/lib/utils/utils.d.ts
CHANGED
package/package.json
CHANGED