connectfy-shared 0.0.89 → 0.0.91
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/index.cjs +28 -13
- package/dist/index.d.cts +23 -8
- package/dist/index.d.ts +23 -8
- package/dist/index.mjs +28 -13
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -11360,14 +11360,19 @@ var BaseRepository = class {
|
|
|
11360
11360
|
// CREATE AND CREATE MANY FUNCTIONS
|
|
11361
11361
|
// ================================================
|
|
11362
11362
|
async create(data, opts) {
|
|
11363
|
+
const virtuals = opts?.lean ?? true;
|
|
11363
11364
|
const newData = new this.model(data);
|
|
11364
11365
|
let saved = await newData.save();
|
|
11365
11366
|
if (opts?.populate) {
|
|
11366
11367
|
saved = await saved.populate(opts.populate);
|
|
11367
11368
|
}
|
|
11368
|
-
return saved.toObject({
|
|
11369
|
+
return saved.toObject({
|
|
11370
|
+
versionKey: false,
|
|
11371
|
+
virtuals
|
|
11372
|
+
});
|
|
11369
11373
|
}
|
|
11370
11374
|
async createMany(data, opts) {
|
|
11375
|
+
const virtuals = opts?.lean ?? true;
|
|
11371
11376
|
const inserted = await this.model.insertMany(data, {
|
|
11372
11377
|
lean: true,
|
|
11373
11378
|
ordered: false
|
|
@@ -11376,9 +11381,14 @@ var BaseRepository = class {
|
|
|
11376
11381
|
const ids = inserted.map((doc) => doc._id);
|
|
11377
11382
|
const populated = await this.model.find({ _id: { $in: ids } }).populate(
|
|
11378
11383
|
opts.populate
|
|
11379
|
-
).lean().exec();
|
|
11384
|
+
).lean({ virtuals, versionKey: false }).exec();
|
|
11380
11385
|
return populated;
|
|
11381
11386
|
}
|
|
11387
|
+
if (virtuals) {
|
|
11388
|
+
return inserted.map(
|
|
11389
|
+
(doc) => doc.toObject({ versionKey: false, virtuals })
|
|
11390
|
+
);
|
|
11391
|
+
}
|
|
11382
11392
|
return inserted;
|
|
11383
11393
|
}
|
|
11384
11394
|
// ================================================
|
|
@@ -11390,7 +11400,7 @@ var BaseRepository = class {
|
|
|
11390
11400
|
new: opts?.new ?? true,
|
|
11391
11401
|
runValidators: opts?.runValidators ?? true,
|
|
11392
11402
|
populate: opts?.populate ?? [],
|
|
11393
|
-
lean: opts?.lean ?? false
|
|
11403
|
+
lean: opts?.lean ?? true ? { virtuals: true, versionKey: false } : false
|
|
11394
11404
|
};
|
|
11395
11405
|
const updatedData = await this.model.findOneAndUpdate(
|
|
11396
11406
|
query,
|
|
@@ -11439,24 +11449,27 @@ var BaseRepository = class {
|
|
|
11439
11449
|
// ================================================
|
|
11440
11450
|
// FINE ONE AND FIND MANY FUNCTIONS
|
|
11441
11451
|
// ================================================
|
|
11442
|
-
async findOne(params = {}) {
|
|
11452
|
+
async findOne(params = {}, opts) {
|
|
11443
11453
|
const {
|
|
11444
11454
|
query = {},
|
|
11445
11455
|
fields = "",
|
|
11446
11456
|
sort = { createdAt: -1 },
|
|
11447
11457
|
populate = []
|
|
11448
11458
|
} = params;
|
|
11449
|
-
|
|
11459
|
+
const virtuals = opts?.lean ?? true;
|
|
11460
|
+
return await this.model.findOne(query).select(fields).sort(sort).populate(populate).lean({ virtuals, versionKey: false }).exec();
|
|
11450
11461
|
}
|
|
11451
|
-
async findOneById(_id, params = {}) {
|
|
11462
|
+
async findOneById(_id, params = {}, opts) {
|
|
11452
11463
|
const { fields = "", sort = { createdAt: -1 }, populate = [] } = params;
|
|
11453
|
-
|
|
11464
|
+
const virtuals = opts?.lean ?? true;
|
|
11465
|
+
return await this.model.findOne({ _id }).select(fields).sort(sort).populate(populate).lean({ virtuals, versionKey: false }).exec();
|
|
11454
11466
|
}
|
|
11455
|
-
async findOneByUserId(userId, params = {}) {
|
|
11467
|
+
async findOneByUserId(userId, params = {}, opts) {
|
|
11456
11468
|
const { fields = "", sort = { createdAt: -1 }, populate = [] } = params;
|
|
11457
|
-
|
|
11469
|
+
const virtuals = opts?.lean ?? true;
|
|
11470
|
+
return await this.model.findOne({ userId }).select(fields).sort(sort).populate(populate).lean({ virtuals, versionKey: false }).exec();
|
|
11458
11471
|
}
|
|
11459
|
-
async findMany(params = {}) {
|
|
11472
|
+
async findMany(params = {}, opts) {
|
|
11460
11473
|
const {
|
|
11461
11474
|
query = {},
|
|
11462
11475
|
fields = "",
|
|
@@ -11465,16 +11478,18 @@ var BaseRepository = class {
|
|
|
11465
11478
|
skip = 0,
|
|
11466
11479
|
limit = 10
|
|
11467
11480
|
} = params;
|
|
11468
|
-
|
|
11481
|
+
const virtuals = opts?.lean ?? true;
|
|
11482
|
+
return await this.model.find(query).select(fields).skip(skip).limit(limit).sort(sort).populate(populate).lean({ virtuals, versionKey: false }).exec();
|
|
11469
11483
|
}
|
|
11470
|
-
async findAll(params = {}) {
|
|
11484
|
+
async findAll(params = {}, opts) {
|
|
11471
11485
|
const {
|
|
11472
11486
|
query = {},
|
|
11473
11487
|
fields = "",
|
|
11474
11488
|
sort = { createdAt: -1 },
|
|
11475
11489
|
populate = []
|
|
11476
11490
|
} = params;
|
|
11477
|
-
|
|
11491
|
+
const virtuals = opts?.lean ?? true;
|
|
11492
|
+
return await this.model.find(query).select(fields).sort(sort).populate(populate).lean({ virtuals, versionKey: false }).exec();
|
|
11478
11493
|
}
|
|
11479
11494
|
// ================================================
|
|
11480
11495
|
// EXIST AND COUNT FUNCTIONS
|
package/dist/index.d.cts
CHANGED
|
@@ -577,11 +577,26 @@ declare function decryptPayload(payload: string, base64Key: string): string;
|
|
|
577
577
|
declare function sendWithContext<TResponse = any>({ client, endpoint, payload, }: ISendWithContextClientParams): Promise<TResponse>;
|
|
578
578
|
declare function emitWithContext({ client, topic, payload, }: IEmitWithContextClientParams): rxjs.Observable<any>;
|
|
579
579
|
|
|
580
|
-
interface ILoggedUser extends
|
|
580
|
+
interface ILoggedUser extends IReturnedUser {
|
|
581
581
|
language: LANGUAGE;
|
|
582
582
|
avatar: string | null;
|
|
583
583
|
}
|
|
584
|
-
interface
|
|
584
|
+
interface IReturnedUser {
|
|
585
|
+
_id: string;
|
|
586
|
+
username: string;
|
|
587
|
+
email: string;
|
|
588
|
+
phoneNumber: IPhoneNumber;
|
|
589
|
+
isTwoFactorEnabled: boolean;
|
|
590
|
+
timeZone: string | null;
|
|
591
|
+
location: string | null;
|
|
592
|
+
usesPasswordAuth: boolean;
|
|
593
|
+
usesOAuth: boolean;
|
|
594
|
+
hasPhoneNumber: boolean;
|
|
595
|
+
accountAgeInDays: number;
|
|
596
|
+
createdAt: Date;
|
|
597
|
+
updatedAt: Date;
|
|
598
|
+
}
|
|
599
|
+
interface IReturnedUser {
|
|
585
600
|
_id: string;
|
|
586
601
|
username: string;
|
|
587
602
|
email: string;
|
|
@@ -745,13 +760,13 @@ declare abstract class BaseRepository<TDocument extends Document, TInterface ext
|
|
|
745
760
|
remove(data: BaseRemoveDto, opts?: IBaseRepositoryRemoveOptions): Promise<TInterface>;
|
|
746
761
|
removeOne(query: Record<string, any>, opts?: IBaseRepositoryRemoveOptions): Promise<TInterface>;
|
|
747
762
|
removeMany(data: BaseRemoveAllDto, opts?: IBaseRepositoryRemoveOptions): Promise<TInterface[]>;
|
|
748
|
-
findOne(params?: BaseFindDto): Promise<TInterface | null>;
|
|
749
|
-
findOneById(_id: string, params?: BaseFindDto): Promise<TInterface | null>;
|
|
750
|
-
findOneByUserId(userId: string, params?: BaseFindDto): Promise<TInterface | null>;
|
|
751
|
-
findMany(params?: BaseFindDto): Promise<TInterface[]>;
|
|
752
|
-
findAll(params?: BaseFindDto): Promise<TInterface[]>;
|
|
763
|
+
findOne(params?: BaseFindDto, opts?: IBaseRepositoryOptions): Promise<TInterface | null>;
|
|
764
|
+
findOneById(_id: string, params?: BaseFindDto, opts?: IBaseRepositoryOptions): Promise<TInterface | null>;
|
|
765
|
+
findOneByUserId(userId: string, params?: BaseFindDto, opts?: IBaseRepositoryOptions): Promise<TInterface | null>;
|
|
766
|
+
findMany(params?: BaseFindDto, opts?: IBaseRepositoryOptions): Promise<TInterface[]>;
|
|
767
|
+
findAll(params?: BaseFindDto, opts?: IBaseRepositoryOptions): Promise<TInterface[]>;
|
|
753
768
|
existsByField(query: Record<string, any>): Promise<boolean>;
|
|
754
769
|
count(query: Record<string, any>): Promise<number>;
|
|
755
770
|
}
|
|
756
771
|
|
|
757
|
-
export { AllExceptionsFilter, BROWSER_TYPE, BaseException, BaseFindDto, BaseRemoveAllDto, BaseRemoveDto, BaseRepository, CACHE_KEYS, CHECK_UNIQUE_FIELD, CLS_KEYS, COLLECTIONS, COUNTRIES, DATE_FORMAT, DELETE_REASON, DELETE_REASON_CODE, DEVICE_TYPE, EXPIRE_DATES, ExceptionMessages, FIELD_TRANSFORMER_REGISTRY, FIELD_TYPE, FIELD_VALIDATOR_REGISTRY, FORGOT_PASSWORD_IDENTIFIER_TYPE, FRIENDSHIP_STATUS, FieldValidator, type FieldValidatorOptions, GENDER, GOOGLE_AUTH_LOGIN_TYPE, HttpStatus, type IAccount, type IArrayFieldOptions, type IBaseFieldOptions, type IBaseRepositoryInterface, type IBaseRepositoryOptions, type IBaseRepositoryRemoveOptions, type IBaseRepositoryUpdateOptions, type IBooleanFieldOptions, type ICountry, IDENTIFIER_TYPE, type IDateFieldOptions, type IEmitWithContextClientParams, type IEnumFieldOptions, type IGeneralSettings, type ILoggedUser, type INotificationSettings, type INumberFieldOptions, type IObjectFieldOptions, type IPhoneNumber, type IPrivacySettings, type IRemoveAllResponse, type
|
|
772
|
+
export { AllExceptionsFilter, BROWSER_TYPE, BaseException, BaseFindDto, BaseRemoveAllDto, BaseRemoveDto, BaseRepository, CACHE_KEYS, CHECK_UNIQUE_FIELD, CLS_KEYS, COLLECTIONS, COUNTRIES, DATE_FORMAT, DELETE_REASON, DELETE_REASON_CODE, DEVICE_TYPE, EXPIRE_DATES, ExceptionMessages, FIELD_TRANSFORMER_REGISTRY, FIELD_TYPE, FIELD_VALIDATOR_REGISTRY, FORGOT_PASSWORD_IDENTIFIER_TYPE, FRIENDSHIP_STATUS, FieldValidator, type FieldValidatorOptions, GENDER, GOOGLE_AUTH_LOGIN_TYPE, HttpStatus, type IAccount, type IArrayFieldOptions, type IBaseFieldOptions, type IBaseRepositoryInterface, type IBaseRepositoryOptions, type IBaseRepositoryRemoveOptions, type IBaseRepositoryUpdateOptions, type IBooleanFieldOptions, type ICountry, IDENTIFIER_TYPE, type IDateFieldOptions, type IEmitWithContextClientParams, type IEnumFieldOptions, type IGeneralSettings, type ILoggedUser, type INotificationSettings, type INumberFieldOptions, type IObjectFieldOptions, type IPhoneNumber, type IPrivacySettings, type IRemoveAllResponse, type IReturnedUser, type ISendWithContextClientParams, type IStringFieldOptions, type ITimeZone, type IValidateMessageOptions, LANGUAGE, LOCAL_STORAGE_KEYS, MICROSERVICE_NAMES, NOTIFICATION_CONTENT_MODE, NOTIFICATION_SOUND_MODE, OS_TYPE, PHONE_NUMBER_ACTION, PRIVACY_SETTINGS_CHOICE, PROVIDER, PopulateOption, REDIS_KEYS, REDUCER_PATH, RESOURCE, ROLE, SOCIAL_LINK_PLATFORM, STARTUP_PAGE, TAG_TYPES, THEME, TIME_DIFFERENCE_TYPE, TIME_FORMAT, TOKEN_TYPE, USER_STATUS, VALIDATION_TYPE, accountDeletedMessage, arrayTransform, booleanTransform, changeEmailMessage, dateTransform, decryptPayload, deleteAccountMessage, emailNotFoundMessage, emitWithContext, encryptPayload, enumTransform, forgotPasswordMessage, getLang, googleSignInMessage, lowerCaseTranform, numberTransform, objectTransform, sendWithContext, signupVerifyMessage, stringTransform, upperCaseTranform, validationMessage, verifyYourselfMessage };
|
package/dist/index.d.ts
CHANGED
|
@@ -577,11 +577,26 @@ declare function decryptPayload(payload: string, base64Key: string): string;
|
|
|
577
577
|
declare function sendWithContext<TResponse = any>({ client, endpoint, payload, }: ISendWithContextClientParams): Promise<TResponse>;
|
|
578
578
|
declare function emitWithContext({ client, topic, payload, }: IEmitWithContextClientParams): rxjs.Observable<any>;
|
|
579
579
|
|
|
580
|
-
interface ILoggedUser extends
|
|
580
|
+
interface ILoggedUser extends IReturnedUser {
|
|
581
581
|
language: LANGUAGE;
|
|
582
582
|
avatar: string | null;
|
|
583
583
|
}
|
|
584
|
-
interface
|
|
584
|
+
interface IReturnedUser {
|
|
585
|
+
_id: string;
|
|
586
|
+
username: string;
|
|
587
|
+
email: string;
|
|
588
|
+
phoneNumber: IPhoneNumber;
|
|
589
|
+
isTwoFactorEnabled: boolean;
|
|
590
|
+
timeZone: string | null;
|
|
591
|
+
location: string | null;
|
|
592
|
+
usesPasswordAuth: boolean;
|
|
593
|
+
usesOAuth: boolean;
|
|
594
|
+
hasPhoneNumber: boolean;
|
|
595
|
+
accountAgeInDays: number;
|
|
596
|
+
createdAt: Date;
|
|
597
|
+
updatedAt: Date;
|
|
598
|
+
}
|
|
599
|
+
interface IReturnedUser {
|
|
585
600
|
_id: string;
|
|
586
601
|
username: string;
|
|
587
602
|
email: string;
|
|
@@ -745,13 +760,13 @@ declare abstract class BaseRepository<TDocument extends Document, TInterface ext
|
|
|
745
760
|
remove(data: BaseRemoveDto, opts?: IBaseRepositoryRemoveOptions): Promise<TInterface>;
|
|
746
761
|
removeOne(query: Record<string, any>, opts?: IBaseRepositoryRemoveOptions): Promise<TInterface>;
|
|
747
762
|
removeMany(data: BaseRemoveAllDto, opts?: IBaseRepositoryRemoveOptions): Promise<TInterface[]>;
|
|
748
|
-
findOne(params?: BaseFindDto): Promise<TInterface | null>;
|
|
749
|
-
findOneById(_id: string, params?: BaseFindDto): Promise<TInterface | null>;
|
|
750
|
-
findOneByUserId(userId: string, params?: BaseFindDto): Promise<TInterface | null>;
|
|
751
|
-
findMany(params?: BaseFindDto): Promise<TInterface[]>;
|
|
752
|
-
findAll(params?: BaseFindDto): Promise<TInterface[]>;
|
|
763
|
+
findOne(params?: BaseFindDto, opts?: IBaseRepositoryOptions): Promise<TInterface | null>;
|
|
764
|
+
findOneById(_id: string, params?: BaseFindDto, opts?: IBaseRepositoryOptions): Promise<TInterface | null>;
|
|
765
|
+
findOneByUserId(userId: string, params?: BaseFindDto, opts?: IBaseRepositoryOptions): Promise<TInterface | null>;
|
|
766
|
+
findMany(params?: BaseFindDto, opts?: IBaseRepositoryOptions): Promise<TInterface[]>;
|
|
767
|
+
findAll(params?: BaseFindDto, opts?: IBaseRepositoryOptions): Promise<TInterface[]>;
|
|
753
768
|
existsByField(query: Record<string, any>): Promise<boolean>;
|
|
754
769
|
count(query: Record<string, any>): Promise<number>;
|
|
755
770
|
}
|
|
756
771
|
|
|
757
|
-
export { AllExceptionsFilter, BROWSER_TYPE, BaseException, BaseFindDto, BaseRemoveAllDto, BaseRemoveDto, BaseRepository, CACHE_KEYS, CHECK_UNIQUE_FIELD, CLS_KEYS, COLLECTIONS, COUNTRIES, DATE_FORMAT, DELETE_REASON, DELETE_REASON_CODE, DEVICE_TYPE, EXPIRE_DATES, ExceptionMessages, FIELD_TRANSFORMER_REGISTRY, FIELD_TYPE, FIELD_VALIDATOR_REGISTRY, FORGOT_PASSWORD_IDENTIFIER_TYPE, FRIENDSHIP_STATUS, FieldValidator, type FieldValidatorOptions, GENDER, GOOGLE_AUTH_LOGIN_TYPE, HttpStatus, type IAccount, type IArrayFieldOptions, type IBaseFieldOptions, type IBaseRepositoryInterface, type IBaseRepositoryOptions, type IBaseRepositoryRemoveOptions, type IBaseRepositoryUpdateOptions, type IBooleanFieldOptions, type ICountry, IDENTIFIER_TYPE, type IDateFieldOptions, type IEmitWithContextClientParams, type IEnumFieldOptions, type IGeneralSettings, type ILoggedUser, type INotificationSettings, type INumberFieldOptions, type IObjectFieldOptions, type IPhoneNumber, type IPrivacySettings, type IRemoveAllResponse, type
|
|
772
|
+
export { AllExceptionsFilter, BROWSER_TYPE, BaseException, BaseFindDto, BaseRemoveAllDto, BaseRemoveDto, BaseRepository, CACHE_KEYS, CHECK_UNIQUE_FIELD, CLS_KEYS, COLLECTIONS, COUNTRIES, DATE_FORMAT, DELETE_REASON, DELETE_REASON_CODE, DEVICE_TYPE, EXPIRE_DATES, ExceptionMessages, FIELD_TRANSFORMER_REGISTRY, FIELD_TYPE, FIELD_VALIDATOR_REGISTRY, FORGOT_PASSWORD_IDENTIFIER_TYPE, FRIENDSHIP_STATUS, FieldValidator, type FieldValidatorOptions, GENDER, GOOGLE_AUTH_LOGIN_TYPE, HttpStatus, type IAccount, type IArrayFieldOptions, type IBaseFieldOptions, type IBaseRepositoryInterface, type IBaseRepositoryOptions, type IBaseRepositoryRemoveOptions, type IBaseRepositoryUpdateOptions, type IBooleanFieldOptions, type ICountry, IDENTIFIER_TYPE, type IDateFieldOptions, type IEmitWithContextClientParams, type IEnumFieldOptions, type IGeneralSettings, type ILoggedUser, type INotificationSettings, type INumberFieldOptions, type IObjectFieldOptions, type IPhoneNumber, type IPrivacySettings, type IRemoveAllResponse, type IReturnedUser, type ISendWithContextClientParams, type IStringFieldOptions, type ITimeZone, type IValidateMessageOptions, LANGUAGE, LOCAL_STORAGE_KEYS, MICROSERVICE_NAMES, NOTIFICATION_CONTENT_MODE, NOTIFICATION_SOUND_MODE, OS_TYPE, PHONE_NUMBER_ACTION, PRIVACY_SETTINGS_CHOICE, PROVIDER, PopulateOption, REDIS_KEYS, REDUCER_PATH, RESOURCE, ROLE, SOCIAL_LINK_PLATFORM, STARTUP_PAGE, TAG_TYPES, THEME, TIME_DIFFERENCE_TYPE, TIME_FORMAT, TOKEN_TYPE, USER_STATUS, VALIDATION_TYPE, accountDeletedMessage, arrayTransform, booleanTransform, changeEmailMessage, dateTransform, decryptPayload, deleteAccountMessage, emailNotFoundMessage, emitWithContext, encryptPayload, enumTransform, forgotPasswordMessage, getLang, googleSignInMessage, lowerCaseTranform, numberTransform, objectTransform, sendWithContext, signupVerifyMessage, stringTransform, upperCaseTranform, validationMessage, verifyYourselfMessage };
|
package/dist/index.mjs
CHANGED
|
@@ -11317,14 +11317,19 @@ var BaseRepository = class {
|
|
|
11317
11317
|
// CREATE AND CREATE MANY FUNCTIONS
|
|
11318
11318
|
// ================================================
|
|
11319
11319
|
async create(data, opts) {
|
|
11320
|
+
const virtuals = opts?.lean ?? true;
|
|
11320
11321
|
const newData = new this.model(data);
|
|
11321
11322
|
let saved = await newData.save();
|
|
11322
11323
|
if (opts?.populate) {
|
|
11323
11324
|
saved = await saved.populate(opts.populate);
|
|
11324
11325
|
}
|
|
11325
|
-
return saved.toObject({
|
|
11326
|
+
return saved.toObject({
|
|
11327
|
+
versionKey: false,
|
|
11328
|
+
virtuals
|
|
11329
|
+
});
|
|
11326
11330
|
}
|
|
11327
11331
|
async createMany(data, opts) {
|
|
11332
|
+
const virtuals = opts?.lean ?? true;
|
|
11328
11333
|
const inserted = await this.model.insertMany(data, {
|
|
11329
11334
|
lean: true,
|
|
11330
11335
|
ordered: false
|
|
@@ -11333,9 +11338,14 @@ var BaseRepository = class {
|
|
|
11333
11338
|
const ids = inserted.map((doc) => doc._id);
|
|
11334
11339
|
const populated = await this.model.find({ _id: { $in: ids } }).populate(
|
|
11335
11340
|
opts.populate
|
|
11336
|
-
).lean().exec();
|
|
11341
|
+
).lean({ virtuals, versionKey: false }).exec();
|
|
11337
11342
|
return populated;
|
|
11338
11343
|
}
|
|
11344
|
+
if (virtuals) {
|
|
11345
|
+
return inserted.map(
|
|
11346
|
+
(doc) => doc.toObject({ versionKey: false, virtuals })
|
|
11347
|
+
);
|
|
11348
|
+
}
|
|
11339
11349
|
return inserted;
|
|
11340
11350
|
}
|
|
11341
11351
|
// ================================================
|
|
@@ -11347,7 +11357,7 @@ var BaseRepository = class {
|
|
|
11347
11357
|
new: opts?.new ?? true,
|
|
11348
11358
|
runValidators: opts?.runValidators ?? true,
|
|
11349
11359
|
populate: opts?.populate ?? [],
|
|
11350
|
-
lean: opts?.lean ?? false
|
|
11360
|
+
lean: opts?.lean ?? true ? { virtuals: true, versionKey: false } : false
|
|
11351
11361
|
};
|
|
11352
11362
|
const updatedData = await this.model.findOneAndUpdate(
|
|
11353
11363
|
query,
|
|
@@ -11396,24 +11406,27 @@ var BaseRepository = class {
|
|
|
11396
11406
|
// ================================================
|
|
11397
11407
|
// FINE ONE AND FIND MANY FUNCTIONS
|
|
11398
11408
|
// ================================================
|
|
11399
|
-
async findOne(params = {}) {
|
|
11409
|
+
async findOne(params = {}, opts) {
|
|
11400
11410
|
const {
|
|
11401
11411
|
query = {},
|
|
11402
11412
|
fields = "",
|
|
11403
11413
|
sort = { createdAt: -1 },
|
|
11404
11414
|
populate = []
|
|
11405
11415
|
} = params;
|
|
11406
|
-
|
|
11416
|
+
const virtuals = opts?.lean ?? true;
|
|
11417
|
+
return await this.model.findOne(query).select(fields).sort(sort).populate(populate).lean({ virtuals, versionKey: false }).exec();
|
|
11407
11418
|
}
|
|
11408
|
-
async findOneById(_id, params = {}) {
|
|
11419
|
+
async findOneById(_id, params = {}, opts) {
|
|
11409
11420
|
const { fields = "", sort = { createdAt: -1 }, populate = [] } = params;
|
|
11410
|
-
|
|
11421
|
+
const virtuals = opts?.lean ?? true;
|
|
11422
|
+
return await this.model.findOne({ _id }).select(fields).sort(sort).populate(populate).lean({ virtuals, versionKey: false }).exec();
|
|
11411
11423
|
}
|
|
11412
|
-
async findOneByUserId(userId, params = {}) {
|
|
11424
|
+
async findOneByUserId(userId, params = {}, opts) {
|
|
11413
11425
|
const { fields = "", sort = { createdAt: -1 }, populate = [] } = params;
|
|
11414
|
-
|
|
11426
|
+
const virtuals = opts?.lean ?? true;
|
|
11427
|
+
return await this.model.findOne({ userId }).select(fields).sort(sort).populate(populate).lean({ virtuals, versionKey: false }).exec();
|
|
11415
11428
|
}
|
|
11416
|
-
async findMany(params = {}) {
|
|
11429
|
+
async findMany(params = {}, opts) {
|
|
11417
11430
|
const {
|
|
11418
11431
|
query = {},
|
|
11419
11432
|
fields = "",
|
|
@@ -11422,16 +11435,18 @@ var BaseRepository = class {
|
|
|
11422
11435
|
skip = 0,
|
|
11423
11436
|
limit = 10
|
|
11424
11437
|
} = params;
|
|
11425
|
-
|
|
11438
|
+
const virtuals = opts?.lean ?? true;
|
|
11439
|
+
return await this.model.find(query).select(fields).skip(skip).limit(limit).sort(sort).populate(populate).lean({ virtuals, versionKey: false }).exec();
|
|
11426
11440
|
}
|
|
11427
|
-
async findAll(params = {}) {
|
|
11441
|
+
async findAll(params = {}, opts) {
|
|
11428
11442
|
const {
|
|
11429
11443
|
query = {},
|
|
11430
11444
|
fields = "",
|
|
11431
11445
|
sort = { createdAt: -1 },
|
|
11432
11446
|
populate = []
|
|
11433
11447
|
} = params;
|
|
11434
|
-
|
|
11448
|
+
const virtuals = opts?.lean ?? true;
|
|
11449
|
+
return await this.model.find(query).select(fields).sort(sort).populate(populate).lean({ virtuals, versionKey: false }).exec();
|
|
11435
11450
|
}
|
|
11436
11451
|
// ================================================
|
|
11437
11452
|
// EXIST AND COUNT FUNCTIONS
|