@tstdl/base 0.93.26 → 0.93.27
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/orm/server/repository.js
CHANGED
|
@@ -173,8 +173,10 @@ let EntityRepository = class EntityRepository extends Transactional {
|
|
|
173
173
|
.exhaustive()
|
|
174
174
|
: isSimilar(query, searchExpression);
|
|
175
175
|
const distanceColumn = distance(query, searchExpression).as(searchDistanceColumn);
|
|
176
|
+
const score = sql `1 - ${distance(query, searchExpression)}`.as(searchScoreColumn);
|
|
176
177
|
const selection = fromEntries(this.#columnDefinitions.map((column) => [column.name, this.resolveTargetColumn(column)]));
|
|
177
178
|
selection[searchDistanceColumn] = distanceColumn;
|
|
179
|
+
selection[searchScoreColumn] = score;
|
|
178
180
|
const whereClause = isDefined(filter)
|
|
179
181
|
? and(this.convertQuery(filter), trigramClause)
|
|
180
182
|
: trigramClause;
|
|
@@ -190,7 +192,6 @@ let EntityRepository = class EntityRepository extends Transactional {
|
|
|
190
192
|
dbQuery = dbQuery.limit(options.limit);
|
|
191
193
|
}
|
|
192
194
|
const orderByExpressions = [];
|
|
193
|
-
const score = sql `1 - ${distanceColumn}`;
|
|
194
195
|
if (isDefined(options.order)) {
|
|
195
196
|
const order = isFunction(options.order) ? options.order({ score }) : options.order;
|
|
196
197
|
orderByExpressions.push(...this.convertOrderBy(order));
|
package/package.json
CHANGED
package/test1.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import './polyfills.js';
|
|
2
2
|
import { Application, provideInitializer, provideModule, provideSignalHandler } from './application/index.js';
|
|
3
3
|
import { migrateAuditSchema } from './audit/index.js';
|
|
4
|
-
import { AuthenticationService } from './authentication/server/authentication.service.js';
|
|
5
4
|
import { configureAuthenticationServer } from './authentication/server/module.js';
|
|
6
|
-
import { inject,
|
|
5
|
+
import { inject, Injector, runInInjectionContext } from './injector/index.js';
|
|
7
6
|
import { configurePostgresKeyValueStore, migratePostgresKeyValueStoreSchema } from './key-value-store/postgres/module.js';
|
|
8
7
|
import { configurePostgresLock, migratePostgresLockSchema } from './lock/postgres/index.js';
|
|
9
8
|
import { PrettyPrintLogFormatter, provideConsoleLogTransport } from './logger/index.js';
|
|
@@ -51,16 +50,19 @@ async function bootstrap() {
|
|
|
51
50
|
}
|
|
52
51
|
async function main(_cancellationSignal) {
|
|
53
52
|
const repository = injectRepository(Test);
|
|
54
|
-
const authService = await injectAsync(AuthenticationService);
|
|
55
53
|
if (await repository.count() == 0) {
|
|
56
54
|
await repository.insertMany(testData);
|
|
57
55
|
}
|
|
58
56
|
const result = await repository.search({
|
|
59
57
|
query: {
|
|
60
|
-
$
|
|
61
|
-
|
|
58
|
+
$trigram: {
|
|
59
|
+
fields: ['title'],
|
|
60
|
+
query: 'lorem ipsum dolor sit amet',
|
|
62
61
|
},
|
|
63
62
|
},
|
|
63
|
+
distinct: ['title'],
|
|
64
|
+
order: (x) => ['title', x.score],
|
|
65
|
+
limit: 10,
|
|
64
66
|
});
|
|
65
67
|
console.log(result);
|
|
66
68
|
}
|
|
File without changes
|