elseware-nodejs 1.7.10 → 1.8.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 +1 -1
- package/dist/index.cjs +82 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -2
- package/dist/index.d.ts +44 -2
- package/dist/index.js +81 -2
- package/dist/index.js.map +1 -1
- package/package.json +76 -76
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
# elseware-nodejs
|
|
1
|
+
# elseware-nodejs
|
package/dist/index.cjs
CHANGED
|
@@ -5176,6 +5176,84 @@ var validate = (schema) => (req, _res, next) => {
|
|
|
5176
5176
|
}
|
|
5177
5177
|
next();
|
|
5178
5178
|
};
|
|
5179
|
+
|
|
5180
|
+
// src/repositories/mongo.repository.ts
|
|
5181
|
+
var BaseMongoRepository = class {
|
|
5182
|
+
model;
|
|
5183
|
+
constructor(model) {
|
|
5184
|
+
this.model = model;
|
|
5185
|
+
}
|
|
5186
|
+
async findAll(filter = {}, options = {}) {
|
|
5187
|
+
let query = this.model.find(filter);
|
|
5188
|
+
if (options.select) query = query.select(options.select);
|
|
5189
|
+
if (options.sort) query = query.sort(options.sort);
|
|
5190
|
+
if (options.limit) query = query.limit(options.limit);
|
|
5191
|
+
if (options.skip) query = query.skip(options.skip);
|
|
5192
|
+
return query.exec();
|
|
5193
|
+
}
|
|
5194
|
+
async findById(id) {
|
|
5195
|
+
return this.model.findById(id).exec();
|
|
5196
|
+
}
|
|
5197
|
+
async findOne(filter) {
|
|
5198
|
+
return this.model.findOne(filter).exec();
|
|
5199
|
+
}
|
|
5200
|
+
async create(data) {
|
|
5201
|
+
return this.model.create(data);
|
|
5202
|
+
}
|
|
5203
|
+
async updateById(id, data) {
|
|
5204
|
+
return this.model.findByIdAndUpdate(id, data, {
|
|
5205
|
+
new: true,
|
|
5206
|
+
runValidators: true
|
|
5207
|
+
}).exec();
|
|
5208
|
+
}
|
|
5209
|
+
async deleteById(id) {
|
|
5210
|
+
return this.model.findByIdAndDelete(id).exec();
|
|
5211
|
+
}
|
|
5212
|
+
};
|
|
5213
|
+
|
|
5214
|
+
// src/repositories/postgres.repository.ts
|
|
5215
|
+
var BasePostgresRepository = class {
|
|
5216
|
+
model;
|
|
5217
|
+
// prisma model (e.g. prisma.testPost)
|
|
5218
|
+
constructor(model) {
|
|
5219
|
+
this.model = model;
|
|
5220
|
+
}
|
|
5221
|
+
async findAll(filter = {}, options = {}) {
|
|
5222
|
+
return this.model.findMany({
|
|
5223
|
+
where: filter,
|
|
5224
|
+
select: options.select,
|
|
5225
|
+
orderBy: options.sort,
|
|
5226
|
+
take: options.limit,
|
|
5227
|
+
skip: options.skip
|
|
5228
|
+
});
|
|
5229
|
+
}
|
|
5230
|
+
async findById(id) {
|
|
5231
|
+
return this.model.findUnique({
|
|
5232
|
+
where: { id }
|
|
5233
|
+
});
|
|
5234
|
+
}
|
|
5235
|
+
async findOne(filter) {
|
|
5236
|
+
return this.model.findFirst({
|
|
5237
|
+
where: filter
|
|
5238
|
+
});
|
|
5239
|
+
}
|
|
5240
|
+
async create(data) {
|
|
5241
|
+
return this.model.create({
|
|
5242
|
+
data
|
|
5243
|
+
});
|
|
5244
|
+
}
|
|
5245
|
+
async updateById(id, data) {
|
|
5246
|
+
return this.model.update({
|
|
5247
|
+
where: { id },
|
|
5248
|
+
data
|
|
5249
|
+
});
|
|
5250
|
+
}
|
|
5251
|
+
async deleteById(id) {
|
|
5252
|
+
return this.model.delete({
|
|
5253
|
+
where: { id }
|
|
5254
|
+
});
|
|
5255
|
+
}
|
|
5256
|
+
};
|
|
5179
5257
|
var AzureBlobStorageService = class {
|
|
5180
5258
|
containerName;
|
|
5181
5259
|
blobServiceClient;
|
|
@@ -5290,7 +5368,8 @@ var CloudinaryService = class {
|
|
|
5290
5368
|
const result = await cloudinary.uploader.upload(filePath, {
|
|
5291
5369
|
folder: folderPath,
|
|
5292
5370
|
public_id: options.publicId,
|
|
5293
|
-
resource_type: options.resourceType || "auto"
|
|
5371
|
+
resource_type: options.resourceType || "auto",
|
|
5372
|
+
transformation: options.transformation
|
|
5294
5373
|
});
|
|
5295
5374
|
return result.public_id;
|
|
5296
5375
|
}
|
|
@@ -5637,6 +5716,8 @@ exports.AppError = AppError;
|
|
|
5637
5716
|
exports.AzureBlobStorageService = AzureBlobStorageService;
|
|
5638
5717
|
exports.BPlusTree = BPlusTree;
|
|
5639
5718
|
exports.BTree = BTree;
|
|
5719
|
+
exports.BaseMongoRepository = BaseMongoRepository;
|
|
5720
|
+
exports.BasePostgresRepository = BasePostgresRepository;
|
|
5640
5721
|
exports.BinaryHeap = BinaryHeap;
|
|
5641
5722
|
exports.BinarySearchTree = BinarySearchTree;
|
|
5642
5723
|
exports.BinaryTree = BinaryTree;
|