@cheetah.js/orm 0.1.140 → 0.1.141
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.
|
@@ -75,11 +75,12 @@ async function withDatabase(arg1, arg2, arg3) {
|
|
|
75
75
|
const session = await createSession(targetOptions);
|
|
76
76
|
cachedSession = {
|
|
77
77
|
orm: session.orm,
|
|
78
|
-
tables: [],
|
|
79
78
|
schema: session.schema,
|
|
79
|
+
storage: session.storage,
|
|
80
80
|
};
|
|
81
81
|
sessionCache.set(cacheKey, cachedSession);
|
|
82
82
|
}
|
|
83
|
+
activateSession(cachedSession);
|
|
83
84
|
const context = buildContext(cachedSession.orm);
|
|
84
85
|
await dropAndRecreateSchema(context, cachedSession.schema);
|
|
85
86
|
await prepareSchema(context, cachedSession.schema);
|
|
@@ -89,8 +90,9 @@ async function withDatabase(arg1, arg2, arg3) {
|
|
|
89
90
|
async function createSession(options) {
|
|
90
91
|
const logger = selectLogger(options);
|
|
91
92
|
const orm = new orm_1.Orm(logger);
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
const storage = new entities_1.EntityStorage();
|
|
94
|
+
await initializeOrm(orm, storage, options);
|
|
95
|
+
return { orm, schema: options.schema ?? DEFAULT_SCHEMA, storage };
|
|
94
96
|
}
|
|
95
97
|
function selectLogger(options) {
|
|
96
98
|
if (options.logger) {
|
|
@@ -99,8 +101,7 @@ function selectLogger(options) {
|
|
|
99
101
|
const config = { applicationConfig: { logger: { level: 'info' } } };
|
|
100
102
|
return new core_1.LoggerService(config);
|
|
101
103
|
}
|
|
102
|
-
async function initializeOrm(orm, options) {
|
|
103
|
-
const storage = new entities_1.EntityStorage();
|
|
104
|
+
async function initializeOrm(orm, storage, options) {
|
|
104
105
|
if (options.entityFile) {
|
|
105
106
|
const entityFiles = await (0, globby_1.default)(options.entityFile, { absolute: true });
|
|
106
107
|
for (const file of entityFiles) {
|
|
@@ -111,6 +112,10 @@ async function initializeOrm(orm, options) {
|
|
|
111
112
|
const connection = resolveConnection(options.connection);
|
|
112
113
|
await service.onInit(connection);
|
|
113
114
|
}
|
|
115
|
+
function activateSession(session) {
|
|
116
|
+
orm_1.Orm.instance = session.orm;
|
|
117
|
+
entities_1.EntityStorage.instance = session.storage;
|
|
118
|
+
}
|
|
114
119
|
function resolveConnection(overrides) {
|
|
115
120
|
if (!overrides) {
|
|
116
121
|
return DEFAULT_CONNECTION;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cheetah.js/orm",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.141",
|
|
4
4
|
"description": "A simple ORM for Cheetah.js.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"bun",
|
|
56
56
|
"value-object"
|
|
57
57
|
],
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "f3f3004bde2d552db43db3ac56b4d286bbfbc7f6"
|
|
59
59
|
}
|