nongo-driver 2.12.6 → 3.0.0
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/atlas-api.js +6 -6
- package/dist/atlas-api.js.map +1 -1
- package/dist/cursor-iterator.d.ts +1 -2
- package/dist/cursor-iterator.js +3 -1
- package/dist/cursor-iterator.js.map +1 -1
- package/dist/generate-interfaces.js +24 -7
- package/dist/generate-interfaces.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +33 -17
- package/dist/index.js.map +1 -1
- package/dist/interface/atlas/field.d.ts +1 -1
- package/dist/interface/atlas/field.js +1 -0
- package/dist/interface/atlas/field.js.map +1 -1
- package/dist/interface/atlas/index.js +15 -4
- package/dist/interface/atlas/index.js.map +1 -1
- package/dist/interface/index.d.ts +1 -10
- package/dist/interface/index.js +15 -4
- package/dist/interface/index.js.map +1 -1
- package/dist/model.d.ts +12 -13
- package/dist/model.js +26 -29
- package/dist/model.js.map +1 -1
- package/dist/mongo-index.d.ts +2 -3
- package/dist/mongo-index.js.map +1 -1
- package/dist/nongo.d.ts +1 -1
- package/dist/nongo.js +17 -21
- package/dist/nongo.js.map +1 -1
- package/dist/schema-parser.js +10 -10
- package/dist/schema-parser.js.map +1 -1
- package/dist/ts-interface-generator.js +18 -2
- package/dist/ts-interface-generator.js.map +1 -1
- package/dist/validator.js +1 -1
- package/dist/validator.js.map +1 -1
- package/package.json +16 -24
- package/src/atlas-api.ts +11 -40
- package/src/cursor-iterator.ts +1 -3
- package/src/index.ts +1 -1
- package/src/interface/index.ts +0 -11
- package/src/model.ts +25 -39
- package/src/mongo-index.ts +1 -3
- package/src/nongo.ts +1 -5
- package/test/database-helper.ts +26 -13
- package/test/models/dummy-model-changed-obj.ts +12 -0
- package/test/models/dummy-model-obj.ts +40 -0
- package/test/models/dummy-model-with-max-index-obj.ts +195 -0
- package/test/models/text-index-model-modified-obj.ts +12 -0
- package/test/models/text-index-model-obj.ts +11 -0
- package/test/models/text-index-model-too-long-obj.ts +11 -0
- package/test/nongo-multi.test.ts +2 -5
- package/test/nongo.test.ts +125 -172
package/test/database-helper.ts
CHANGED
|
@@ -2,9 +2,22 @@ import {MongoClient} from 'mongodb';
|
|
|
2
2
|
import {MongoMemoryServer} from 'mongodb-memory-server';
|
|
3
3
|
import {Newable, NongoParams} from '../src';
|
|
4
4
|
import Nongo from '../src/nongo';
|
|
5
|
+
import Logger from 'wbb-logger';
|
|
6
|
+
|
|
7
|
+
const logger = new Logger("database-helper.ts");
|
|
8
|
+
|
|
9
|
+
let mongoMemoryServer: MongoMemoryServer;
|
|
10
|
+
|
|
11
|
+
const getInMemoryServer = async () => {
|
|
12
|
+
if (!mongoMemoryServer) {
|
|
13
|
+
logger.info("Using in memory server.");
|
|
14
|
+
mongoMemoryServer = await MongoMemoryServer.create();
|
|
15
|
+
}
|
|
16
|
+
return mongoMemoryServer;
|
|
17
|
+
};
|
|
5
18
|
|
|
6
|
-
const mongoMemoryServer = new MongoMemoryServer();
|
|
7
19
|
export default class DatabaseHelper {
|
|
20
|
+
public static DB_NAME = 'testing';
|
|
8
21
|
public static async getNongoInstance(models: Newable[]): Promise<Nongo> {
|
|
9
22
|
return await new Nongo(
|
|
10
23
|
await DatabaseHelper.getNongoParams(),
|
|
@@ -13,27 +26,27 @@ export default class DatabaseHelper {
|
|
|
13
26
|
}
|
|
14
27
|
|
|
15
28
|
public static async getNongoParams(): Promise<NongoParams> {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
logger.info("Fetching in memory server.");
|
|
30
|
+
const mongod = await getInMemoryServer();
|
|
31
|
+
return {
|
|
32
|
+
protocol: null,
|
|
33
|
+
uri: mongod.getUri(),
|
|
34
|
+
db: DatabaseHelper.DB_NAME,
|
|
35
|
+
};
|
|
21
36
|
}
|
|
22
37
|
|
|
23
38
|
public static async getClient(): Promise<MongoClient> {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
useUnifiedTopology: true,
|
|
27
|
-
});
|
|
39
|
+
const mongod = await getInMemoryServer();
|
|
40
|
+
return MongoClient.connect(await mongod.getUri());
|
|
28
41
|
}
|
|
29
42
|
|
|
30
|
-
public static
|
|
31
|
-
return
|
|
43
|
+
public static getDbName(): string {
|
|
44
|
+
return DatabaseHelper.DB_NAME;
|
|
32
45
|
}
|
|
33
46
|
|
|
34
47
|
public static async drop(): Promise<void> {
|
|
35
48
|
const client = await DatabaseHelper.getClient();
|
|
36
|
-
const db = client.db(
|
|
49
|
+
const db = client.db(DatabaseHelper.getDbName());
|
|
37
50
|
await db.dropDatabase();
|
|
38
51
|
await client.close();
|
|
39
52
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// This file was generated using nongo-driver's TsInterfaceGenerator.
|
|
2
|
+
export default interface DummyModelChangedObj {
|
|
3
|
+
'name': string;
|
|
4
|
+
'pets': Array<{
|
|
5
|
+
'species'?: string;
|
|
6
|
+
'likes'?: {
|
|
7
|
+
'food'?: string[];
|
|
8
|
+
'drink'?: string[];
|
|
9
|
+
};
|
|
10
|
+
}>;
|
|
11
|
+
'_id'?: any;
|
|
12
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// This file was generated using nongo-driver's TsInterfaceGenerator.
|
|
2
|
+
export default interface DummyModelObj {
|
|
3
|
+
'dontStripChildren'?: any;
|
|
4
|
+
'dontStripChildren2'?: any;
|
|
5
|
+
'exampleMap'?: {[key: string]: {
|
|
6
|
+
'mapValueField': string;
|
|
7
|
+
}};
|
|
8
|
+
'created'?: Date;
|
|
9
|
+
'arrayOfObject'?: object[];
|
|
10
|
+
'name': string;
|
|
11
|
+
'age': number;
|
|
12
|
+
'pets': Array<{
|
|
13
|
+
'species'?: string;
|
|
14
|
+
'likes'?: {
|
|
15
|
+
'food'?: string[];
|
|
16
|
+
'drink'?: string[];
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
'job': {
|
|
20
|
+
'role': string;
|
|
21
|
+
'at'?: string;
|
|
22
|
+
};
|
|
23
|
+
'location'?: {
|
|
24
|
+
'address1'?: string;
|
|
25
|
+
};
|
|
26
|
+
'autoInit': {
|
|
27
|
+
'initArray': Array<{
|
|
28
|
+
'nestedObj': any;
|
|
29
|
+
}>;
|
|
30
|
+
'initNestedObj'?: {
|
|
31
|
+
'hello'?: string;
|
|
32
|
+
};
|
|
33
|
+
'initNestedNative'?: any;
|
|
34
|
+
};
|
|
35
|
+
'notEmptyFields'?: {
|
|
36
|
+
'aString': string;
|
|
37
|
+
'anArray': string[];
|
|
38
|
+
};
|
|
39
|
+
'_id'?: any;
|
|
40
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
// This file was generated using nongo-driver's TsInterfaceGenerator.
|
|
2
|
+
export default interface DummyModelWithMaxIndexObj {
|
|
3
|
+
'clients'?: {
|
|
4
|
+
'client1'?: {
|
|
5
|
+
'favouritePet'?: string;
|
|
6
|
+
};
|
|
7
|
+
'client2'?: {
|
|
8
|
+
'favouritePet'?: string;
|
|
9
|
+
};
|
|
10
|
+
'client3'?: {
|
|
11
|
+
'favouritePet'?: string;
|
|
12
|
+
};
|
|
13
|
+
'client4'?: {
|
|
14
|
+
'favouritePet'?: string;
|
|
15
|
+
};
|
|
16
|
+
'client5'?: {
|
|
17
|
+
'favouritePet'?: string;
|
|
18
|
+
};
|
|
19
|
+
'client6'?: {
|
|
20
|
+
'favouritePet'?: string;
|
|
21
|
+
};
|
|
22
|
+
'client7'?: {
|
|
23
|
+
'favouritePet'?: string;
|
|
24
|
+
};
|
|
25
|
+
'client8'?: {
|
|
26
|
+
'favouritePet'?: string;
|
|
27
|
+
};
|
|
28
|
+
'client9'?: {
|
|
29
|
+
'favouritePet'?: string;
|
|
30
|
+
};
|
|
31
|
+
'client10'?: {
|
|
32
|
+
'favouritePet'?: string;
|
|
33
|
+
};
|
|
34
|
+
'client11'?: {
|
|
35
|
+
'favouritePet'?: string;
|
|
36
|
+
};
|
|
37
|
+
'client12'?: {
|
|
38
|
+
'favouritePet'?: string;
|
|
39
|
+
};
|
|
40
|
+
'client13'?: {
|
|
41
|
+
'favouritePet'?: string;
|
|
42
|
+
};
|
|
43
|
+
'client14'?: {
|
|
44
|
+
'favouritePet'?: string;
|
|
45
|
+
};
|
|
46
|
+
'client15'?: {
|
|
47
|
+
'favouritePet'?: string;
|
|
48
|
+
};
|
|
49
|
+
'client16'?: {
|
|
50
|
+
'favouritePet'?: string;
|
|
51
|
+
};
|
|
52
|
+
'client17'?: {
|
|
53
|
+
'favouritePet'?: string;
|
|
54
|
+
};
|
|
55
|
+
'client18'?: {
|
|
56
|
+
'favouritePet'?: string;
|
|
57
|
+
};
|
|
58
|
+
'client19'?: {
|
|
59
|
+
'favouritePet'?: string;
|
|
60
|
+
};
|
|
61
|
+
'client20'?: {
|
|
62
|
+
'favouritePet'?: string;
|
|
63
|
+
};
|
|
64
|
+
'client21'?: {
|
|
65
|
+
'favouritePet'?: string;
|
|
66
|
+
};
|
|
67
|
+
'client22'?: {
|
|
68
|
+
'favouritePet'?: string;
|
|
69
|
+
};
|
|
70
|
+
'client23'?: {
|
|
71
|
+
'favouritePet'?: string;
|
|
72
|
+
};
|
|
73
|
+
'client24'?: {
|
|
74
|
+
'favouritePet'?: string;
|
|
75
|
+
};
|
|
76
|
+
'client25'?: {
|
|
77
|
+
'favouritePet'?: string;
|
|
78
|
+
};
|
|
79
|
+
'client26'?: {
|
|
80
|
+
'favouritePet'?: string;
|
|
81
|
+
};
|
|
82
|
+
'client27'?: {
|
|
83
|
+
'favouritePet'?: string;
|
|
84
|
+
};
|
|
85
|
+
'client28'?: {
|
|
86
|
+
'favouritePet'?: string;
|
|
87
|
+
};
|
|
88
|
+
'client29'?: {
|
|
89
|
+
'favouritePet'?: string;
|
|
90
|
+
};
|
|
91
|
+
'client30'?: {
|
|
92
|
+
'favouritePet'?: string;
|
|
93
|
+
};
|
|
94
|
+
'client31'?: {
|
|
95
|
+
'favouritePet'?: string;
|
|
96
|
+
};
|
|
97
|
+
'client32'?: {
|
|
98
|
+
'favouritePet'?: string;
|
|
99
|
+
};
|
|
100
|
+
'client33'?: {
|
|
101
|
+
'favouritePet'?: string;
|
|
102
|
+
};
|
|
103
|
+
'client34'?: {
|
|
104
|
+
'favouritePet'?: string;
|
|
105
|
+
};
|
|
106
|
+
'client35'?: {
|
|
107
|
+
'favouritePet'?: string;
|
|
108
|
+
};
|
|
109
|
+
'client36'?: {
|
|
110
|
+
'favouritePet'?: string;
|
|
111
|
+
};
|
|
112
|
+
'client37'?: {
|
|
113
|
+
'favouritePet'?: string;
|
|
114
|
+
};
|
|
115
|
+
'client38'?: {
|
|
116
|
+
'favouritePet'?: string;
|
|
117
|
+
};
|
|
118
|
+
'client39'?: {
|
|
119
|
+
'favouritePet'?: string;
|
|
120
|
+
};
|
|
121
|
+
'client40'?: {
|
|
122
|
+
'favouritePet'?: string;
|
|
123
|
+
};
|
|
124
|
+
'client41'?: {
|
|
125
|
+
'favouritePet'?: string;
|
|
126
|
+
};
|
|
127
|
+
'client42'?: {
|
|
128
|
+
'favouritePet'?: string;
|
|
129
|
+
};
|
|
130
|
+
'client43'?: {
|
|
131
|
+
'favouritePet'?: string;
|
|
132
|
+
};
|
|
133
|
+
'client44'?: {
|
|
134
|
+
'favouritePet'?: string;
|
|
135
|
+
};
|
|
136
|
+
'client45'?: {
|
|
137
|
+
'favouritePet'?: string;
|
|
138
|
+
};
|
|
139
|
+
'client46'?: {
|
|
140
|
+
'favouritePet'?: string;
|
|
141
|
+
};
|
|
142
|
+
'client47'?: {
|
|
143
|
+
'favouritePet'?: string;
|
|
144
|
+
};
|
|
145
|
+
'client48'?: {
|
|
146
|
+
'favouritePet'?: string;
|
|
147
|
+
};
|
|
148
|
+
'client49'?: {
|
|
149
|
+
'favouritePet'?: string;
|
|
150
|
+
};
|
|
151
|
+
'client50'?: {
|
|
152
|
+
'favouritePet'?: string;
|
|
153
|
+
};
|
|
154
|
+
'client51'?: {
|
|
155
|
+
'favouritePet'?: string;
|
|
156
|
+
};
|
|
157
|
+
'client52'?: {
|
|
158
|
+
'favouritePet'?: string;
|
|
159
|
+
};
|
|
160
|
+
'client53'?: {
|
|
161
|
+
'favouritePet'?: string;
|
|
162
|
+
};
|
|
163
|
+
'client54'?: {
|
|
164
|
+
'favouritePet'?: string;
|
|
165
|
+
};
|
|
166
|
+
'client55'?: {
|
|
167
|
+
'favouritePet'?: string;
|
|
168
|
+
};
|
|
169
|
+
'client56'?: {
|
|
170
|
+
'favouritePet'?: string;
|
|
171
|
+
};
|
|
172
|
+
'client57'?: {
|
|
173
|
+
'favouritePet'?: string;
|
|
174
|
+
};
|
|
175
|
+
'client58'?: {
|
|
176
|
+
'favouritePet'?: string;
|
|
177
|
+
};
|
|
178
|
+
'client59'?: {
|
|
179
|
+
'favouritePet'?: string;
|
|
180
|
+
};
|
|
181
|
+
'client60'?: {
|
|
182
|
+
'favouritePet'?: string;
|
|
183
|
+
};
|
|
184
|
+
'client61'?: {
|
|
185
|
+
'favouritePet'?: string;
|
|
186
|
+
};
|
|
187
|
+
'client62'?: {
|
|
188
|
+
'favouritePet'?: string;
|
|
189
|
+
};
|
|
190
|
+
'client63'?: {
|
|
191
|
+
'favouritePet'?: string;
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
'_id'?: any;
|
|
195
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// This file was generated using nongo-driver's TsInterfaceGenerator.
|
|
2
|
+
export default interface TextIndexModelModifiedObj {
|
|
3
|
+
'name'?: string;
|
|
4
|
+
'module'?: string;
|
|
5
|
+
'description'?: {
|
|
6
|
+
'en'?: string;
|
|
7
|
+
'cy'?: string;
|
|
8
|
+
'es'?: string;
|
|
9
|
+
};
|
|
10
|
+
'summary'?: string;
|
|
11
|
+
'_id'?: any;
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file was generated using nongo-driver's TsInterfaceGenerator.
|
|
2
|
+
export default interface TextIndexModelTooLongObj {
|
|
3
|
+
'name'?: string;
|
|
4
|
+
'module'?: string;
|
|
5
|
+
'description'?: {
|
|
6
|
+
'en'?: string;
|
|
7
|
+
'cy'?: string;
|
|
8
|
+
};
|
|
9
|
+
'summary'?: string;
|
|
10
|
+
'_id'?: any;
|
|
11
|
+
}
|
package/test/nongo-multi.test.ts
CHANGED
|
@@ -18,10 +18,7 @@ const dbNames = [
|
|
|
18
18
|
|
|
19
19
|
async function drop() {
|
|
20
20
|
for (const dbName of dbNames) {
|
|
21
|
-
const client = await MongoClient
|
|
22
|
-
useNewUrlParser: true,
|
|
23
|
-
useUnifiedTopology: true,
|
|
24
|
-
});
|
|
21
|
+
const client = await new MongoClient('mongodb://127.0.0.1:27017').connect();
|
|
25
22
|
const db = client.db(dbName);
|
|
26
23
|
await db.dropDatabase();
|
|
27
24
|
await client.close();
|
|
@@ -44,7 +41,7 @@ describe('Testing NongoMulti...', () => {
|
|
|
44
41
|
// Create an array of params one for each db name
|
|
45
42
|
const paramsArray = dbNames.map((dbName) => ({
|
|
46
43
|
id: nameToId(dbName),
|
|
47
|
-
host: '
|
|
44
|
+
host: '127.0.0.1',
|
|
48
45
|
port: 27017,
|
|
49
46
|
db: dbName,
|
|
50
47
|
}));
|