@event-driven-io/pongo 0.2.2 → 0.2.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/README.md +2 -2
- package/dist/index.d.cts +11 -11
- package/dist/index.d.ts +11 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -54,7 +54,7 @@ await users.deleteOne({ _id: cruella._id });
|
|
|
54
54
|
const anitaFromDb = await users.findOne({ _id: anitaId });
|
|
55
55
|
|
|
56
56
|
// Finding more
|
|
57
|
-
|
|
57
|
+
const usersFromDb = await users.find({ age: { $lt: 40 } });
|
|
58
58
|
```
|
|
59
59
|
|
|
60
60
|
Or use MongoDB compliant shim:
|
|
@@ -93,7 +93,7 @@ await users.deleteOne({ _id: cruella._id });
|
|
|
93
93
|
const anitaFromDb = await users.findOne({ _id: anitaId });
|
|
94
94
|
|
|
95
95
|
// Finding more
|
|
96
|
-
|
|
96
|
+
const usersFromDb = await users.find({ age: { $lt: 40 } }).toArray();
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
## How does it work?
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Document, Collection as Collection$1, ReadConcern, ReadPreference, BSONSerializeOptions, WriteConcern, Hint, OptionalUnlessRequiredId, InsertOneOptions, InsertOneResult, BulkWriteOptions, InsertManyResult, AnyBulkWriteOperation, BulkWriteResult, Filter, UpdateFilter, UpdateOptions, UpdateResult, WithoutId
|
|
1
|
+
import { Document, Collection as Collection$1, ReadConcern, ReadPreference, BSONSerializeOptions, WriteConcern, Hint, OptionalUnlessRequiredId, InsertOneOptions, InsertOneResult, BulkWriteOptions, InsertManyResult, AnyBulkWriteOperation, BulkWriteResult, Filter, UpdateFilter, UpdateOptions, UpdateResult, WithoutId, ReplaceOptions, DeleteOptions, DeleteResult, RenameOptions, DropCollectionOptions, WithId as WithId$1, FindOptions, FindCursor as FindCursor$1, OperationOptions, IndexSpecification, CreateIndexesOptions, IndexDescription, CommandOperationOptions, AbstractCursorOptions, ListIndexesCursor, IndexInformationOptions, IndexDescriptionInfo, IndexDescriptionCompact, EstimatedDocumentCountOptions, CountDocumentsOptions, EnhancedOmit, Flatten, FindOneAndDeleteOptions, ModifyResult, FindOneAndReplaceOptions, FindOneAndUpdateOptions, AggregateOptions, AggregationCursor, ChangeStreamDocument, ChangeStreamOptions, ChangeStream, UnorderedBulkOperation, OrderedBulkOperation, CountOptions, ListSearchIndexesOptions, ListSearchIndexesCursor, SearchIndexDescription } from 'mongodb';
|
|
2
2
|
import pg from 'pg';
|
|
3
3
|
|
|
4
4
|
interface PongoClient {
|
|
@@ -20,13 +20,13 @@ interface PongoCollection<T> {
|
|
|
20
20
|
findOne(filter: PongoFilter<T>): Promise<T | null>;
|
|
21
21
|
find(filter: PongoFilter<T>): Promise<T[]>;
|
|
22
22
|
}
|
|
23
|
-
type
|
|
23
|
+
type HasId = {
|
|
24
24
|
_id: string;
|
|
25
25
|
};
|
|
26
|
-
type
|
|
26
|
+
type WithId<T> = T & HasId;
|
|
27
27
|
type PongoFilter<T> = {
|
|
28
|
-
[P in keyof T]?:
|
|
29
|
-
};
|
|
28
|
+
[P in keyof T]?: T[P] | PongoFilterOperator<T[P]>;
|
|
29
|
+
} | HasId;
|
|
30
30
|
type PongoFilterOperator<T> = {
|
|
31
31
|
$eq?: T;
|
|
32
32
|
$gt?: T;
|
|
@@ -141,7 +141,7 @@ declare class Collection<T extends Document> implements Collection$1<T> {
|
|
|
141
141
|
insertMany(docs: OptionalUnlessRequiredId<T>[], _options?: BulkWriteOptions | undefined): Promise<InsertManyResult<T>>;
|
|
142
142
|
bulkWrite(_operations: AnyBulkWriteOperation<T>[], _options?: BulkWriteOptions | undefined): Promise<BulkWriteResult>;
|
|
143
143
|
updateOne(filter: Filter<T>, update: Document[] | UpdateFilter<T>, _options?: UpdateOptions | undefined): Promise<UpdateResult<T>>;
|
|
144
|
-
replaceOne(_filter: Filter<T>, _: WithoutId
|
|
144
|
+
replaceOne(_filter: Filter<T>, _: WithoutId<T>, _options?: ReplaceOptions | undefined): Promise<Document | UpdateResult<T>>;
|
|
145
145
|
updateMany(filter: Filter<T>, update: Document[] | UpdateFilter<T>, _options?: UpdateOptions | undefined): Promise<UpdateResult<T>>;
|
|
146
146
|
deleteOne(filter?: Filter<T> | undefined, _options?: DeleteOptions | undefined): Promise<DeleteResult>;
|
|
147
147
|
deleteMany(filter?: Filter<T> | undefined, _options?: DeleteOptions | undefined): Promise<DeleteResult>;
|
|
@@ -196,14 +196,14 @@ declare class Collection<T extends Document> implements Collection$1<T> {
|
|
|
196
196
|
}): Promise<WithId$1<T> | null>;
|
|
197
197
|
findOneAndDelete(filter: Filter<T>, options: FindOneAndDeleteOptions): Promise<WithId$1<T> | null>;
|
|
198
198
|
findOneAndDelete(filter: Filter<T>): Promise<WithId$1<T> | null>;
|
|
199
|
-
findOneAndReplace(filter: Filter<T>, replacement: WithoutId
|
|
199
|
+
findOneAndReplace(filter: Filter<T>, replacement: WithoutId<T>, options: FindOneAndReplaceOptions & {
|
|
200
200
|
includeResultMetadata: true;
|
|
201
201
|
}): Promise<ModifyResult<T>>;
|
|
202
|
-
findOneAndReplace(filter: Filter<T>, replacement: WithoutId
|
|
202
|
+
findOneAndReplace(filter: Filter<T>, replacement: WithoutId<T>, options: FindOneAndReplaceOptions & {
|
|
203
203
|
includeResultMetadata: false;
|
|
204
204
|
}): Promise<WithId$1<T> | null>;
|
|
205
|
-
findOneAndReplace(filter: Filter<T>, replacement: WithoutId
|
|
206
|
-
findOneAndReplace(filter: Filter<T>, replacement: WithoutId
|
|
205
|
+
findOneAndReplace(filter: Filter<T>, replacement: WithoutId<T>, options: FindOneAndReplaceOptions): Promise<WithId$1<T> | null>;
|
|
206
|
+
findOneAndReplace(filter: Filter<T>, replacement: WithoutId<T>): Promise<WithId$1<T> | null>;
|
|
207
207
|
findOneAndUpdate(filter: Filter<T>, update: UpdateFilter<T>, options: FindOneAndUpdateOptions & {
|
|
208
208
|
includeResultMetadata: true;
|
|
209
209
|
}): Promise<ModifyResult<T>>;
|
|
@@ -282,4 +282,4 @@ declare const buildUnsetQuery: <T>(unset: $unset<T>, currentUpdateQuery: SQL) =>
|
|
|
282
282
|
declare const buildIncQuery: <T>(inc: $inc<T>, currentUpdateQuery: SQL) => SQL;
|
|
283
283
|
declare const buildPushQuery: <T>(push: $push<T>, currentUpdateQuery: SQL) => SQL;
|
|
284
284
|
|
|
285
|
-
export { type $inc, type $push, type $set, type $unset, Collection, Db, type DbClient, FindCursor, MongoClient, type NonPartial, type ObjectId, Operators, type PongoClient, type PongoCollection, type PongoDb, type PongoDeleteManyResult, type PongoDeleteResult, type PongoFilter, type PongoFilterOperator, type PongoInsertManyResult, type PongoInsertOneResult, type PongoUpdate, type PongoUpdateManyResult, type PongoUpdateResult, type SQL, type WithId,
|
|
285
|
+
export { type $inc, type $push, type $set, type $unset, Collection, Db, type DbClient, FindCursor, type HasId, MongoClient, type NonPartial, type ObjectId, Operators, type PongoClient, type PongoCollection, type PongoDb, type PongoDeleteManyResult, type PongoDeleteResult, type PongoFilter, type PongoFilterOperator, type PongoInsertManyResult, type PongoInsertOneResult, type PongoUpdate, type PongoUpdateManyResult, type PongoUpdateResult, type SQL, type WithId, buildIncQuery, buildPushQuery, buildSetQuery, buildUnsetQuery, buildUpdateQuery, collectionSQLBuilder, constructFilterQuery, endAllPools, endPool, entries, execute, executeSQL, getDbClient, getPool, handleOperator, hasOperators, isOperator, pongoClient, postgresClient, postgresCollection, sql };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Document, Collection as Collection$1, ReadConcern, ReadPreference, BSONSerializeOptions, WriteConcern, Hint, OptionalUnlessRequiredId, InsertOneOptions, InsertOneResult, BulkWriteOptions, InsertManyResult, AnyBulkWriteOperation, BulkWriteResult, Filter, UpdateFilter, UpdateOptions, UpdateResult, WithoutId
|
|
1
|
+
import { Document, Collection as Collection$1, ReadConcern, ReadPreference, BSONSerializeOptions, WriteConcern, Hint, OptionalUnlessRequiredId, InsertOneOptions, InsertOneResult, BulkWriteOptions, InsertManyResult, AnyBulkWriteOperation, BulkWriteResult, Filter, UpdateFilter, UpdateOptions, UpdateResult, WithoutId, ReplaceOptions, DeleteOptions, DeleteResult, RenameOptions, DropCollectionOptions, WithId as WithId$1, FindOptions, FindCursor as FindCursor$1, OperationOptions, IndexSpecification, CreateIndexesOptions, IndexDescription, CommandOperationOptions, AbstractCursorOptions, ListIndexesCursor, IndexInformationOptions, IndexDescriptionInfo, IndexDescriptionCompact, EstimatedDocumentCountOptions, CountDocumentsOptions, EnhancedOmit, Flatten, FindOneAndDeleteOptions, ModifyResult, FindOneAndReplaceOptions, FindOneAndUpdateOptions, AggregateOptions, AggregationCursor, ChangeStreamDocument, ChangeStreamOptions, ChangeStream, UnorderedBulkOperation, OrderedBulkOperation, CountOptions, ListSearchIndexesOptions, ListSearchIndexesCursor, SearchIndexDescription } from 'mongodb';
|
|
2
2
|
import pg from 'pg';
|
|
3
3
|
|
|
4
4
|
interface PongoClient {
|
|
@@ -20,13 +20,13 @@ interface PongoCollection<T> {
|
|
|
20
20
|
findOne(filter: PongoFilter<T>): Promise<T | null>;
|
|
21
21
|
find(filter: PongoFilter<T>): Promise<T[]>;
|
|
22
22
|
}
|
|
23
|
-
type
|
|
23
|
+
type HasId = {
|
|
24
24
|
_id: string;
|
|
25
25
|
};
|
|
26
|
-
type
|
|
26
|
+
type WithId<T> = T & HasId;
|
|
27
27
|
type PongoFilter<T> = {
|
|
28
|
-
[P in keyof T]?:
|
|
29
|
-
};
|
|
28
|
+
[P in keyof T]?: T[P] | PongoFilterOperator<T[P]>;
|
|
29
|
+
} | HasId;
|
|
30
30
|
type PongoFilterOperator<T> = {
|
|
31
31
|
$eq?: T;
|
|
32
32
|
$gt?: T;
|
|
@@ -141,7 +141,7 @@ declare class Collection<T extends Document> implements Collection$1<T> {
|
|
|
141
141
|
insertMany(docs: OptionalUnlessRequiredId<T>[], _options?: BulkWriteOptions | undefined): Promise<InsertManyResult<T>>;
|
|
142
142
|
bulkWrite(_operations: AnyBulkWriteOperation<T>[], _options?: BulkWriteOptions | undefined): Promise<BulkWriteResult>;
|
|
143
143
|
updateOne(filter: Filter<T>, update: Document[] | UpdateFilter<T>, _options?: UpdateOptions | undefined): Promise<UpdateResult<T>>;
|
|
144
|
-
replaceOne(_filter: Filter<T>, _: WithoutId
|
|
144
|
+
replaceOne(_filter: Filter<T>, _: WithoutId<T>, _options?: ReplaceOptions | undefined): Promise<Document | UpdateResult<T>>;
|
|
145
145
|
updateMany(filter: Filter<T>, update: Document[] | UpdateFilter<T>, _options?: UpdateOptions | undefined): Promise<UpdateResult<T>>;
|
|
146
146
|
deleteOne(filter?: Filter<T> | undefined, _options?: DeleteOptions | undefined): Promise<DeleteResult>;
|
|
147
147
|
deleteMany(filter?: Filter<T> | undefined, _options?: DeleteOptions | undefined): Promise<DeleteResult>;
|
|
@@ -196,14 +196,14 @@ declare class Collection<T extends Document> implements Collection$1<T> {
|
|
|
196
196
|
}): Promise<WithId$1<T> | null>;
|
|
197
197
|
findOneAndDelete(filter: Filter<T>, options: FindOneAndDeleteOptions): Promise<WithId$1<T> | null>;
|
|
198
198
|
findOneAndDelete(filter: Filter<T>): Promise<WithId$1<T> | null>;
|
|
199
|
-
findOneAndReplace(filter: Filter<T>, replacement: WithoutId
|
|
199
|
+
findOneAndReplace(filter: Filter<T>, replacement: WithoutId<T>, options: FindOneAndReplaceOptions & {
|
|
200
200
|
includeResultMetadata: true;
|
|
201
201
|
}): Promise<ModifyResult<T>>;
|
|
202
|
-
findOneAndReplace(filter: Filter<T>, replacement: WithoutId
|
|
202
|
+
findOneAndReplace(filter: Filter<T>, replacement: WithoutId<T>, options: FindOneAndReplaceOptions & {
|
|
203
203
|
includeResultMetadata: false;
|
|
204
204
|
}): Promise<WithId$1<T> | null>;
|
|
205
|
-
findOneAndReplace(filter: Filter<T>, replacement: WithoutId
|
|
206
|
-
findOneAndReplace(filter: Filter<T>, replacement: WithoutId
|
|
205
|
+
findOneAndReplace(filter: Filter<T>, replacement: WithoutId<T>, options: FindOneAndReplaceOptions): Promise<WithId$1<T> | null>;
|
|
206
|
+
findOneAndReplace(filter: Filter<T>, replacement: WithoutId<T>): Promise<WithId$1<T> | null>;
|
|
207
207
|
findOneAndUpdate(filter: Filter<T>, update: UpdateFilter<T>, options: FindOneAndUpdateOptions & {
|
|
208
208
|
includeResultMetadata: true;
|
|
209
209
|
}): Promise<ModifyResult<T>>;
|
|
@@ -282,4 +282,4 @@ declare const buildUnsetQuery: <T>(unset: $unset<T>, currentUpdateQuery: SQL) =>
|
|
|
282
282
|
declare const buildIncQuery: <T>(inc: $inc<T>, currentUpdateQuery: SQL) => SQL;
|
|
283
283
|
declare const buildPushQuery: <T>(push: $push<T>, currentUpdateQuery: SQL) => SQL;
|
|
284
284
|
|
|
285
|
-
export { type $inc, type $push, type $set, type $unset, Collection, Db, type DbClient, FindCursor, MongoClient, type NonPartial, type ObjectId, Operators, type PongoClient, type PongoCollection, type PongoDb, type PongoDeleteManyResult, type PongoDeleteResult, type PongoFilter, type PongoFilterOperator, type PongoInsertManyResult, type PongoInsertOneResult, type PongoUpdate, type PongoUpdateManyResult, type PongoUpdateResult, type SQL, type WithId,
|
|
285
|
+
export { type $inc, type $push, type $set, type $unset, Collection, Db, type DbClient, FindCursor, type HasId, MongoClient, type NonPartial, type ObjectId, Operators, type PongoClient, type PongoCollection, type PongoDb, type PongoDeleteManyResult, type PongoDeleteResult, type PongoFilter, type PongoFilterOperator, type PongoInsertManyResult, type PongoInsertOneResult, type PongoUpdate, type PongoUpdateManyResult, type PongoUpdateResult, type SQL, type WithId, buildIncQuery, buildPushQuery, buildSetQuery, buildUnsetQuery, buildUpdateQuery, collectionSQLBuilder, constructFilterQuery, endAllPools, endPool, entries, execute, executeSQL, getDbClient, getPool, handleOperator, hasOperators, isOperator, pongoClient, postgresClient, postgresCollection, sql };
|