This repository has been archived by the owner on May 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
98 lines (79 loc) · 2.5 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**
* Author Malindu Warapitiya
*/
var CargoConnect = require('./connect');
var CargoFunctions = require('./operations');
var CargoOptions = require('./options');
var CargoError = require('./error');
var async = require('async');
var _models = {};
var _record = {};
var _options = {};
exports.express = function (config, opts, cb) {
opts = opts || {};
//Connect to the database
var db = CargoConnect(config);
async.series({
criticalSection: function (callback) {
CargoFunctions(db, opts).then(function (d) {
_models = d.models;
_record = d.record;
callback(null, true);
});
}
},
function (err) {
if (err) {
return CargoError("CONNECTION_ERROR", err);
}
cb();
_options = CargoOptions;
});
return function CargoExpressMiddleware(req, res, next) {
req.models = _models;
req.record = _record;
req.cargo = _options;
if (next === undefined && typeof res === 'function') {
next = res;
}
return next();
}
};
/**
* Database bootstrap method
* @type {{CREATEOREXISTS: number, DROPANDCREATE: number}}
*/
exports.sync = {
CREATEOREXISTS: 1,
DROPANDCREATE: 2
};
/**
* A list of orientdb data types, indexed by their type id.
* @type {Object}
*/
exports.types = {
"BOOLEAN": {index: 0, type: 'Boolean'},
"INTEGER": {index: 1, type: 'Integer'},
"SHORT": {index: 2, type: 'Short'},
"LONG": {index: 3, type: 'Long'},
"FLOAT": {index: 4, type: 'Float'},
"DOUBLE": {index: 5, type: 'Double'},
"DATETIME": {index: 6, type: 'Datetime'},
"STRING": {index: 7, type: 'String'},
"BINARY": {index: 8, type: 'Binary'},
"EMBEDDED": {index: 9, type: 'Embedded'},
"EMBEDDEDLIST": {index: 10, type: 'EmbeddedList'},
"EMBEDDEDSET": {index: 11, type: 'EmbeddedSet'},
"EMBEDDEDMAP": {index: 12, type: 'EmbeddedMap'},
"LINK": {index: 13, type: 'Link'},
"LINKLIST": {index: 14, type: 'LinkList'},
"LINKSET": {index: 15, type: 'LinkSet'},
"LINKMAP": {index: 16, type: 'LinkMap'},
"BYTE": {index: 17, type: 'Byte'},
"TRANSIENT": {index: 18, type: 'Transient'},
"DATE": {index: 19, type: 'Date'},
"CUSTOM": {index: 20, type: 'Custom'},
"DECIMAL": {index: 21, type: 'Decimal'},
"LINKBAG": {index: 22, type: 'LinkBag'},
"ANY": {index: 23, type: 'Any'}
};