spice-js 2.5.13 → 2.5.14
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/build/bootstrap/database.js +6 -3
- package/build/bootstrap/map.js +7 -2
- package/build/loaders/index.js +1 -1
- package/build/models/SpiceModel.js +4 -1
- package/package.json +1 -1
- package/src/bootstrap/database.js +6 -4
- package/src/bootstrap/map.js +6 -2
- package/src/loaders/index.js +1 -1
- package/src/models/SpiceModel.js +4 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
4
|
|
|
@@ -7,6 +7,8 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
7
7
|
spice.database = {};
|
|
8
8
|
spice.database.connections = {};
|
|
9
9
|
spice.database.clusters = {};
|
|
10
|
+
spice.database.scopes = {};
|
|
11
|
+
spice.database.buckets = {};
|
|
10
12
|
|
|
11
13
|
function connect() {
|
|
12
14
|
return _connect.apply(this, arguments);
|
|
@@ -25,6 +27,8 @@ function _connect() {
|
|
|
25
27
|
var result = yield connection.connect(key, value);
|
|
26
28
|
spice.database.connections[result.connection] = result.collection;
|
|
27
29
|
spice.database.clusters[result.connection] = result.cluster;
|
|
30
|
+
spice.database.scopes[result.connection] = result.scope;
|
|
31
|
+
spice.database.buckets[result.connection] = result.bucket;
|
|
28
32
|
}
|
|
29
33
|
}
|
|
30
34
|
} catch (e) {
|
|
@@ -35,5 +39,4 @@ function _connect() {
|
|
|
35
39
|
return _connect.apply(this, arguments);
|
|
36
40
|
}
|
|
37
41
|
|
|
38
|
-
module.exports = connect;
|
|
39
|
-
;
|
|
42
|
+
module.exports = connect;
|
package/build/bootstrap/map.js
CHANGED
|
@@ -23,8 +23,13 @@ try {
|
|
|
23
23
|
/*#__PURE__*/
|
|
24
24
|
function () {
|
|
25
25
|
var _ref = _asyncToGenerator(function* (file) {
|
|
26
|
-
|
|
27
|
-
spice[resource][
|
|
26
|
+
var file_name = file.split(".")[0];
|
|
27
|
+
spice[resource][file_name.toLowerCase()] = (yield Promise.resolve("" + _path.default.join(paths, file)).then(s => _interopRequireWildcard(require(s)))).default;
|
|
28
|
+
spice[resource][file_name] = (yield Promise.resolve("" + _path.default.join(paths, file)).then(s => _interopRequireWildcard(require(s)))).default;
|
|
29
|
+
|
|
30
|
+
if (resource == "models") {
|
|
31
|
+
new spice[resource][file_name]({});
|
|
32
|
+
}
|
|
28
33
|
});
|
|
29
34
|
|
|
30
35
|
return function (_x) {
|
package/build/loaders/index.js
CHANGED
|
@@ -15,7 +15,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
15
15
|
|
|
16
16
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
17
17
|
|
|
18
|
-
var ordered_modules = ["
|
|
18
|
+
var ordered_modules = ["database", "map", "logger", "error"];
|
|
19
19
|
var last_modules = ["views", "routes"];
|
|
20
20
|
|
|
21
21
|
function load() {
|
|
@@ -85,7 +85,10 @@ class SpiceModel {
|
|
|
85
85
|
delete args.args["ctx"];
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
this[_database] = new Database(args.connection || "default"
|
|
88
|
+
this[_database] = new Database(args.connection || "default", {
|
|
89
|
+
collection: args.collection,
|
|
90
|
+
scope: args.scope
|
|
91
|
+
});
|
|
89
92
|
this[_props] = args.props;
|
|
90
93
|
|
|
91
94
|
for (var i in args.props) {
|
package/package.json
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
spice.database = {};
|
|
4
4
|
spice.database.connections = {};
|
|
5
|
-
spice.database.clusters = {}
|
|
5
|
+
spice.database.clusters = {};
|
|
6
|
+
spice.database.scopes = {};
|
|
7
|
+
spice.database.buckets = {};
|
|
6
8
|
|
|
7
9
|
async function connect() {
|
|
8
10
|
try {
|
|
9
11
|
for (let key in spice.config.database.connections) {
|
|
10
12
|
let value = spice.config.database.connections[key];
|
|
11
|
-
|
|
12
13
|
if (value.enabled) {
|
|
13
14
|
let Database = require(`spice-${value.type}`);
|
|
14
15
|
let connection = new Database();
|
|
15
16
|
let result = await connection.connect(key, value);
|
|
16
17
|
spice.database.connections[result.connection] = result.collection;
|
|
17
18
|
spice.database.clusters[result.connection] = result.cluster;
|
|
19
|
+
spice.database.scopes[result.connection] = result.scope;
|
|
20
|
+
spice.database.buckets[result.connection] = result.bucket;
|
|
18
21
|
}
|
|
19
22
|
}
|
|
20
23
|
} catch (e) {
|
|
@@ -23,4 +26,3 @@ async function connect() {
|
|
|
23
26
|
}
|
|
24
27
|
}
|
|
25
28
|
module.exports = connect;
|
|
26
|
-
;
|
package/src/bootstrap/map.js
CHANGED
|
@@ -8,12 +8,16 @@ try {
|
|
|
8
8
|
require("fs")
|
|
9
9
|
.readdirSync(paths)
|
|
10
10
|
.forEach(async function (file) {
|
|
11
|
-
|
|
11
|
+
let file_name = file.split(".")[0];
|
|
12
|
+
spice[resource][file_name.toLowerCase()] = (
|
|
12
13
|
await import(path.join(paths, file))
|
|
13
14
|
).default;
|
|
14
|
-
spice[resource][
|
|
15
|
+
spice[resource][file_name] = (
|
|
15
16
|
await import(path.join(paths, file))
|
|
16
17
|
).default;
|
|
18
|
+
if (resource == "models") {
|
|
19
|
+
new spice[resource][file_name]({});
|
|
20
|
+
}
|
|
17
21
|
});
|
|
18
22
|
});
|
|
19
23
|
} catch (error) {
|
package/src/loaders/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import path from "path";
|
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import _ from "lodash";
|
|
4
4
|
|
|
5
|
-
let ordered_modules = ["
|
|
5
|
+
let ordered_modules = ["database", "map", "logger", "error"];
|
|
6
6
|
let last_modules = ["views", "routes"];
|
|
7
7
|
export async function load() {
|
|
8
8
|
try {
|
package/src/models/SpiceModel.js
CHANGED
|
@@ -72,7 +72,10 @@ export default class SpiceModel {
|
|
|
72
72
|
if (args.args) {
|
|
73
73
|
delete args.args["ctx"];
|
|
74
74
|
}
|
|
75
|
-
this[_database] = new Database(args.connection || "default"
|
|
75
|
+
this[_database] = new Database(args.connection || "default", {
|
|
76
|
+
collection: args.collection,
|
|
77
|
+
scope: args.scope,
|
|
78
|
+
});
|
|
76
79
|
this[_props] = args.props;
|
|
77
80
|
for (let i in args.props) {
|
|
78
81
|
if (args.args != undefined) {
|