adapt-authoring-mongodb 1.0.0 → 1.1.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/.github/workflows/standardjs.yml +13 -0
- package/index.js +2 -3
- package/lib/MongoDBModule.js +2 -1
- package/lib/typedefs.js +1 -1
- package/package.json +1 -2
- package/.eslintignore +0 -1
- package/.eslintrc +0 -14
- package/tests/mongoDBModule.spec.js +0 -109
- package/tests/objectIdUtils.spec.js +0 -37
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
name: Standard.js formatting check
|
|
2
|
+
on: push
|
|
3
|
+
jobs:
|
|
4
|
+
default:
|
|
5
|
+
runs-on: ubuntu-latest
|
|
6
|
+
steps:
|
|
7
|
+
- uses: actions/checkout@master
|
|
8
|
+
- uses: actions/setup-node@master
|
|
9
|
+
with:
|
|
10
|
+
node-version: 'lts/*'
|
|
11
|
+
cache: 'npm'
|
|
12
|
+
- run: npm ci
|
|
13
|
+
- run: npx standard
|
package/index.js
CHANGED
|
@@ -2,6 +2,5 @@
|
|
|
2
2
|
* MongoDB integration
|
|
3
3
|
* @namespace mongodb
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export { default as ObjectIdUtils } from './lib/ObjectIdUtils.js'
|
|
6
|
+
export { default } from './lib/MongoDBModule.js'
|
package/lib/MongoDBModule.js
CHANGED
|
@@ -125,7 +125,8 @@ class MongoDBModule extends AbstractModule {
|
|
|
125
125
|
this.ObjectId.parseIds(query)
|
|
126
126
|
this.parseOptions(options)
|
|
127
127
|
try {
|
|
128
|
-
|
|
128
|
+
const cursor = this.getCollection(collectionName).find(query, options)
|
|
129
|
+
return options?.returnCursor === true ? cursor : await cursor.toArray()
|
|
129
130
|
} catch (e) {
|
|
130
131
|
this.log('error', `failed to find docs, ${e.message}`)
|
|
131
132
|
throw this.getError(collectionName, 'find', e)
|
package/lib/typedefs.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adapt-authoring-mongodb",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Module for saving to a MongoDB instance",
|
|
5
5
|
"homepage": "https://github.com/adapt-security/adapt-authoring-mongodb",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
"adapt-authoring-core": "github:adapt-security/adapt-authoring-core"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"eslint": "^9.12.0",
|
|
18
17
|
"standard": "^17.1.0",
|
|
19
18
|
"@semantic-release/commit-analyzer": "^9.0.2",
|
|
20
19
|
"@semantic-release/git": "^10.0.1",
|
package/.eslintignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
node_modules
|
package/.eslintrc
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
const MongoDBModule = require('../lib/MongoDBModule');
|
|
2
|
-
const should = require('should');
|
|
3
|
-
|
|
4
|
-
describe('MongoDB module', function() {
|
|
5
|
-
describe('#readyState()', function() {
|
|
6
|
-
it('should return a number', function() {
|
|
7
|
-
false.should.be.true();
|
|
8
|
-
});
|
|
9
|
-
it('should return a value even if no connection', function() {
|
|
10
|
-
false.should.be.true();
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
describe('#isConnected()', function() {
|
|
14
|
-
it('should return true if connected', function() {
|
|
15
|
-
false.should.be.true();
|
|
16
|
-
});
|
|
17
|
-
it('should return false if not connected', function() {
|
|
18
|
-
false.should.be.true();
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
describe('#connectionURI()', function() {
|
|
22
|
-
it('should return a valid connection string', function() {
|
|
23
|
-
false.should.be.true();
|
|
24
|
-
});
|
|
25
|
-
it('should not include undefined values', function() {
|
|
26
|
-
false.should.be.true();
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
describe('#getCollection()', function() {
|
|
30
|
-
it('should return a MongoDB collection', function() {
|
|
31
|
-
false.should.be.true();
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
describe('#connect()', function() {
|
|
35
|
-
it('should establish a connection to specified MongoDB instance', function() {
|
|
36
|
-
false.should.be.true();
|
|
37
|
-
});
|
|
38
|
-
it('should fail gracefully on error', function() {
|
|
39
|
-
false.should.be.true();
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
describe('#insert()', function() {
|
|
43
|
-
it('should return a promise', function() {
|
|
44
|
-
false.should.be.true();
|
|
45
|
-
});
|
|
46
|
-
it('should return an error if no data is passed', function() {
|
|
47
|
-
false.should.be.true();
|
|
48
|
-
});
|
|
49
|
-
it('should return the inserted document', function() {
|
|
50
|
-
false.should.be.true();
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
describe('#find()', function() {
|
|
54
|
-
it('should return a promise', function() {
|
|
55
|
-
false.should.be.true();
|
|
56
|
-
});
|
|
57
|
-
it('should return an error if invalid query data is passed', function() {
|
|
58
|
-
false.should.be.true();
|
|
59
|
-
});
|
|
60
|
-
it('should return an error if invalid model type is specified', function() {
|
|
61
|
-
false.should.be.true();
|
|
62
|
-
});
|
|
63
|
-
it('should populate specified attributes', function() {
|
|
64
|
-
false.should.be.true();
|
|
65
|
-
});
|
|
66
|
-
it('should return matching documents', function() {
|
|
67
|
-
false.should.be.true();
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
describe('#replace()', function() {
|
|
71
|
-
it('should return a promise', function() {
|
|
72
|
-
false.should.be.true();
|
|
73
|
-
});
|
|
74
|
-
it('should return an error if invalid query data is passed', function() {
|
|
75
|
-
false.should.be.true();
|
|
76
|
-
});
|
|
77
|
-
it('should return an error if invalid model type is specified', function() {
|
|
78
|
-
false.should.be.true();
|
|
79
|
-
});
|
|
80
|
-
it('should replace matching document(s)', function() {
|
|
81
|
-
false.should.be.true();
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
describe('#delete()', function() {
|
|
85
|
-
it('should return a promise', function() {
|
|
86
|
-
false.should.be.true();
|
|
87
|
-
});
|
|
88
|
-
it('should return an error if invalid query data is passed', function() {
|
|
89
|
-
false.should.be.true();
|
|
90
|
-
});
|
|
91
|
-
it('should return an error if invalid model type is specified', function() {
|
|
92
|
-
false.should.be.true();
|
|
93
|
-
});
|
|
94
|
-
it('should delete matching document(s)', function() {
|
|
95
|
-
false.should.be.true();
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
describe('#formatError()', function() {
|
|
99
|
-
it('should return an Error', function() {
|
|
100
|
-
false.should.be.true();
|
|
101
|
-
});
|
|
102
|
-
it('should set custom statusCode', function() {
|
|
103
|
-
false.should.be.true();
|
|
104
|
-
});
|
|
105
|
-
it('should set default statusCode', function() {
|
|
106
|
-
false.should.be.true();
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const should = require('should');
|
|
2
|
-
|
|
3
|
-
describe('ObjectId Utils', function() {
|
|
4
|
-
describe('#isValid', function() {
|
|
5
|
-
it('should return false for empty/undefined param', function() {
|
|
6
|
-
false.should.be.true();
|
|
7
|
-
});
|
|
8
|
-
it('should return true for valid string', function() {
|
|
9
|
-
false.should.be.true();
|
|
10
|
-
});
|
|
11
|
-
it('should return true for invalid type', function() {
|
|
12
|
-
false.should.be.true();
|
|
13
|
-
});
|
|
14
|
-
it('should return true for invalid string', function() {
|
|
15
|
-
false.should.be.true();
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
describe('#parse', function() {
|
|
19
|
-
it('should return an ObjectId instance', function() {
|
|
20
|
-
false.should.be.true();
|
|
21
|
-
});
|
|
22
|
-
it('should throw an error on invalid input', function() {
|
|
23
|
-
false.should.be.true();
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
describe('#parseParamIds', function() {
|
|
27
|
-
it('parse a valid _id to an ObjectId', function() {
|
|
28
|
-
false.should.be.true();
|
|
29
|
-
});
|
|
30
|
-
it('throw an error on invalid _id', function() {
|
|
31
|
-
false.should.be.true();
|
|
32
|
-
});
|
|
33
|
-
it('ignore non _id fields', function() {
|
|
34
|
-
false.should.be.true();
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
});
|