File tree 7 files changed +2078
-155
lines changed
7 files changed +2078
-155
lines changed Original file line number Diff line number Diff line change 3
3
* To add additional dependencies, add an export statement.
4
4
*/
5
5
6
- export {
7
- MongoClient ,
8
- Database ,
9
- Collection ,
10
- Bson
6
+ export {
7
+ MongoClient ,
8
+ Database ,
9
+ Collection ,
10
+ Bson
11
11
} from "https://deno.land/x/mongo@v0.29.4/mod.ts" ;
12
12
13
+ export type {
14
+ CountOptions ,
15
+ InsertOptions ,
16
+ UpdateOptions ,
17
+ FindAndModifyOptions ,
18
+ DropOptions ,
19
+ AggregateOptions ,
20
+ FindOptions ,
21
+ DeleteOptions ,
22
+ } from 'https://deno.land/x/mongo@v0.29.4/src/types.ts' ;
23
+
13
24
export {
14
- CountOptions ,
15
- InsertOptions ,
16
- UpdateOptions ,
17
- FindAndModifyOptions ,
18
- DropOptions ,
19
- AggregateOptions ,
20
- FindOptions ,
21
- DeleteOptions ,
22
- } from 'https://deno.land/x/mongo@v0.29.4/src/types.ts' ; }
25
+ afterAll ,
26
+ afterEach ,
27
+ beforeAll ,
28
+ beforeEach ,
29
+ describe ,
30
+ it ,
31
+ } from 'https://deno.land/std@0.138.0/testing/bdd.ts' ;
32
+
33
+ export {
34
+ assert ,
35
+ assertAlmostEquals ,
36
+ assertArrayIncludes ,
37
+ assertEquals ,
38
+ assertExists ,
39
+ assertFalse ,
40
+ assertInstanceOf ,
41
+ assertIsError ,
42
+ assertMatch ,
43
+ assertNotEquals ,
44
+ assertNotMatch ,
45
+ assertNotStrictEquals ,
46
+ assertObjectMatch ,
47
+ assertRejects ,
48
+ assertStrictEquals ,
49
+ assertStringIncludes ,
50
+ assertThrows ,
51
+ equal ,
52
+ fail ,
53
+ unimplemented ,
54
+ unreachable ,
55
+ } from 'https://deno.land/std@0.138.0/testing/asserts.ts' ;
56
+
57
+ import * as dotenv from "https://deno.land/x/dotenv@v3.2.0/mod.ts" ;
58
+ export { dotenv }
Original file line number Diff line number Diff line change @@ -419,19 +419,14 @@ export class SchemaDate {
419
419
if ( typeof convertedDate === 'number' ) {
420
420
if ( isNaN ( convertedDate ) ) {
421
421
return ;
422
+ } else {
423
+ this . convertedValue = new Date ( convertedDate ) ;
422
424
}
423
425
}
424
- else this . convertedValue = convertedDate ;
425
426
}
426
427
427
428
else if ( typeof this . value === 'number' ) {
428
- const convertedDate : number | Date = Date . parse ( this . value . toString ( ) )
429
- if ( typeof convertedDate === 'number' ) {
430
- if ( isNaN ( convertedDate ) ) {
431
- return ;
432
- }
433
- }
434
- else this . convertedValue = convertedDate ;
429
+ this . convertedValue = new Date ( this . value ) ;
435
430
}
436
431
437
432
return this . convertedValue ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -26,6 +26,9 @@ export class Schema {
26
26
27
27
constructor ( schemaObj : Record < string , any > ) {
28
28
29
+ if ( schemaObj === undefined ) {
30
+ throw new Error ( 'Schema requires a valid argument.' ) ;
31
+ }
29
32
this . schemaMap = { } ;
30
33
for ( const property in schemaObj ) {
31
34
if ( typeof schemaObj [ property ] === 'object' ) {
@@ -54,7 +57,7 @@ export interface optionsObject {
54
57
* @returns An object of class SchemaOptions.
55
58
*/
56
59
57
- class SchemaOptions {
60
+ export class SchemaOptions {
58
61
59
62
type : any ;
60
63
required ?: boolean ;
@@ -73,7 +76,12 @@ class SchemaOptions {
73
76
this . validator = null ;
74
77
for ( const key in options ) {
75
78
if ( key === 'type' ) {
76
- this . type = dango . types [ options [ key ] ] ;
79
+ if ( Object . prototype . hasOwnProperty . call ( dango . types , options [ key ] ) ) {
80
+ this . type = dango . types [ options [ key ] ] ;
81
+ }
82
+ else {
83
+ throw new Error ( 'Specified type is invalid' ) ;
84
+ }
77
85
}
78
86
else if ( Object . prototype . hasOwnProperty . call ( this , key ) ) {
79
87
this [ key as keyof optionsObject ] = options [ key as keyof optionsObject ] ;
You can’t perform that action at this time.
0 commit comments