@prisma-next/adapter-mongo 0.4.0-dev.8 → 0.4.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.
@@ -62,6 +62,7 @@ class MongoAdapterImpl implements MongoAdapter {
62
62
  command.collection,
63
63
  lowerFilter(command.filter),
64
64
  this.#lowerUpdate(command.update),
65
+ command.upsert,
65
66
  );
66
67
  case 'insertMany':
67
68
  return new InsertManyWireCommand(
@@ -73,6 +74,7 @@ class MongoAdapterImpl implements MongoAdapter {
73
74
  command.collection,
74
75
  lowerFilter(command.filter),
75
76
  this.#lowerUpdate(command.update),
77
+ command.upsert,
76
78
  );
77
79
  case 'deleteOne':
78
80
  return new DeleteOneWireCommand(command.collection, lowerFilter(command.filter));
@@ -84,9 +86,15 @@ class MongoAdapterImpl implements MongoAdapter {
84
86
  lowerFilter(command.filter),
85
87
  this.#lowerUpdate(command.update),
86
88
  command.upsert,
89
+ command.sort,
90
+ command.returnDocument,
87
91
  );
88
92
  case 'findOneAndDelete':
89
- return new FindOneAndDeleteWireCommand(command.collection, lowerFilter(command.filter));
93
+ return new FindOneAndDeleteWireCommand(
94
+ command.collection,
95
+ lowerFilter(command.filter),
96
+ command.sort,
97
+ );
90
98
  case 'aggregate':
91
99
  return new AggregateWireCommand(command.collection, lowerPipeline(command.pipeline));
92
100
  case 'rawAggregate':
@@ -109,9 +117,11 @@ class MongoAdapterImpl implements MongoAdapter {
109
117
  command.filter,
110
118
  command.update,
111
119
  command.upsert,
120
+ command.sort,
121
+ command.returnDocument,
112
122
  );
113
123
  case 'rawFindOneAndDelete':
114
- return new FindOneAndDeleteWireCommand(command.collection, command.filter);
124
+ return new FindOneAndDeleteWireCommand(command.collection, command.filter, command.sort);
115
125
  // v8 ignore next 4
116
126
  default: {
117
127
  const _exhaustive: never = command;
@@ -1,85 +0,0 @@
1
- import { mongoCodec } from "@prisma-next/mongo-codec";
2
- import { ObjectId } from "mongodb";
3
-
4
- //#region src/core/codec-ids.ts
5
- const MONGO_OBJECTID_CODEC_ID = "mongo/objectId@1";
6
- const MONGO_STRING_CODEC_ID = "mongo/string@1";
7
- const MONGO_DOUBLE_CODEC_ID = "mongo/double@1";
8
- const MONGO_INT32_CODEC_ID = "mongo/int32@1";
9
- const MONGO_BOOLEAN_CODEC_ID = "mongo/bool@1";
10
- const MONGO_DATE_CODEC_ID = "mongo/date@1";
11
- const MONGO_VECTOR_CODEC_ID = "mongo/vector@1";
12
-
13
- //#endregion
14
- //#region src/core/codecs.ts
15
- const mongoObjectIdCodec = mongoCodec({
16
- typeId: MONGO_OBJECTID_CODEC_ID,
17
- targetTypes: ["objectId"],
18
- traits: ["equality"],
19
- decode: (wire) => wire.toHexString(),
20
- encode: (value) => new ObjectId(value)
21
- });
22
- const mongoStringCodec = mongoCodec({
23
- typeId: MONGO_STRING_CODEC_ID,
24
- targetTypes: ["string"],
25
- traits: [
26
- "equality",
27
- "order",
28
- "textual"
29
- ],
30
- decode: (wire) => wire,
31
- encode: (value) => value
32
- });
33
- const mongoDoubleCodec = mongoCodec({
34
- typeId: MONGO_DOUBLE_CODEC_ID,
35
- targetTypes: ["double"],
36
- traits: [
37
- "equality",
38
- "order",
39
- "numeric"
40
- ],
41
- decode: (wire) => wire,
42
- encode: (value) => value
43
- });
44
- const mongoInt32Codec = mongoCodec({
45
- typeId: MONGO_INT32_CODEC_ID,
46
- targetTypes: ["int"],
47
- traits: [
48
- "equality",
49
- "order",
50
- "numeric"
51
- ],
52
- decode: (wire) => wire,
53
- encode: (value) => value
54
- });
55
- const mongoBooleanCodec = mongoCodec({
56
- typeId: MONGO_BOOLEAN_CODEC_ID,
57
- targetTypes: ["bool"],
58
- traits: ["equality", "boolean"],
59
- decode: (wire) => wire,
60
- encode: (value) => value
61
- });
62
- const mongoDateCodec = mongoCodec({
63
- typeId: MONGO_DATE_CODEC_ID,
64
- targetTypes: ["date"],
65
- traits: ["equality", "order"],
66
- decode: (wire) => wire,
67
- encode: (value) => value
68
- });
69
- const mongoVectorCodec = mongoCodec({
70
- typeId: MONGO_VECTOR_CODEC_ID,
71
- targetTypes: ["vector"],
72
- traits: ["equality"],
73
- decode: (wire) => wire,
74
- encode: (value) => value,
75
- renderOutputType: (typeParams) => {
76
- const length = typeParams["length"];
77
- if (length === void 0) return void 0;
78
- if (typeof length !== "number" || !Number.isFinite(length) || !Number.isInteger(length)) throw new Error("renderOutputType: expected positive integer \"length\" for Vector");
79
- return `Vector<${length}>`;
80
- }
81
- });
82
-
83
- //#endregion
84
- export { mongoObjectIdCodec as a, MONGO_INT32_CODEC_ID as c, mongoInt32Codec as i, MONGO_VECTOR_CODEC_ID as l, mongoDateCodec as n, mongoStringCodec as o, mongoDoubleCodec as r, mongoVectorCodec as s, mongoBooleanCodec as t };
85
- //# sourceMappingURL=codecs-DGN3pWRt.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"codecs-DGN3pWRt.mjs","names":[],"sources":["../src/core/codec-ids.ts","../src/core/codecs.ts"],"sourcesContent":["export const MONGO_OBJECTID_CODEC_ID = 'mongo/objectId@1' as const;\nexport const MONGO_STRING_CODEC_ID = 'mongo/string@1' as const;\nexport const MONGO_DOUBLE_CODEC_ID = 'mongo/double@1' as const;\nexport const MONGO_INT32_CODEC_ID = 'mongo/int32@1' as const;\nexport const MONGO_BOOLEAN_CODEC_ID = 'mongo/bool@1' as const;\nexport const MONGO_DATE_CODEC_ID = 'mongo/date@1' as const;\nexport const MONGO_VECTOR_CODEC_ID = 'mongo/vector@1' as const;\n","import { mongoCodec } from '@prisma-next/mongo-codec';\nimport { ObjectId } from 'mongodb';\nimport {\n MONGO_BOOLEAN_CODEC_ID,\n MONGO_DATE_CODEC_ID,\n MONGO_DOUBLE_CODEC_ID,\n MONGO_INT32_CODEC_ID,\n MONGO_OBJECTID_CODEC_ID,\n MONGO_STRING_CODEC_ID,\n MONGO_VECTOR_CODEC_ID,\n} from './codec-ids';\n\nexport const mongoObjectIdCodec = mongoCodec({\n typeId: MONGO_OBJECTID_CODEC_ID,\n targetTypes: ['objectId'],\n traits: ['equality'],\n decode: (wire: ObjectId) => wire.toHexString(),\n encode: (value: string) => new ObjectId(value),\n});\n\nexport const mongoStringCodec = mongoCodec({\n typeId: MONGO_STRING_CODEC_ID,\n targetTypes: ['string'],\n traits: ['equality', 'order', 'textual'],\n decode: (wire: string) => wire,\n encode: (value: string) => value,\n});\n\nexport const mongoDoubleCodec = mongoCodec({\n typeId: MONGO_DOUBLE_CODEC_ID,\n targetTypes: ['double'],\n traits: ['equality', 'order', 'numeric'],\n decode: (wire: number) => wire,\n encode: (value: number) => value,\n});\n\nexport const mongoInt32Codec = mongoCodec({\n typeId: MONGO_INT32_CODEC_ID,\n targetTypes: ['int'],\n traits: ['equality', 'order', 'numeric'],\n decode: (wire: number) => wire,\n encode: (value: number) => value,\n});\n\nexport const mongoBooleanCodec = mongoCodec({\n typeId: MONGO_BOOLEAN_CODEC_ID,\n targetTypes: ['bool'],\n traits: ['equality', 'boolean'],\n decode: (wire: boolean) => wire,\n encode: (value: boolean) => value,\n});\n\nexport const mongoDateCodec = mongoCodec({\n typeId: MONGO_DATE_CODEC_ID,\n targetTypes: ['date'],\n traits: ['equality', 'order'],\n decode: (wire: Date) => wire,\n encode: (value: Date) => value,\n});\n\nexport const mongoVectorCodec = mongoCodec({\n typeId: MONGO_VECTOR_CODEC_ID,\n targetTypes: ['vector'],\n traits: ['equality'],\n decode: (wire: readonly number[]) => wire,\n encode: (value: readonly number[]) => value,\n renderOutputType: (typeParams) => {\n const length = typeParams['length'];\n if (length === undefined) return undefined;\n if (typeof length !== 'number' || !Number.isFinite(length) || !Number.isInteger(length)) {\n throw new Error('renderOutputType: expected positive integer \"length\" for Vector');\n }\n return `Vector<${length}>`;\n },\n});\n"],"mappings":";;;;AAAA,MAAa,0BAA0B;AACvC,MAAa,wBAAwB;AACrC,MAAa,wBAAwB;AACrC,MAAa,uBAAuB;AACpC,MAAa,yBAAyB;AACtC,MAAa,sBAAsB;AACnC,M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