Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

remult

Package Overview
Dependencies
Maintainers
0
Versions
618
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remult - npm Package Compare versions

Comparing version 0.26.18 to 0.26.19-next.0

6

esm/remult-knex/index.js

@@ -1,2 +0,2 @@

import { CustomSqlFilterBuilder, } from '../src/filter/filter-consumer-bridge-to-sql-request.js';
import { CustomSqlFilterBuilder, dbNamesOfWithForceSqlExpression, } from '../src/filter/filter-consumer-bridge-to-sql-request.js';
import { dbNamesOf, isDbReadonly, shouldCreateEntity, shouldNotCreateField, } from '../src/filter/filter-consumer-bridge-to-sql-request.js';

@@ -95,3 +95,3 @@ import { customDatabaseFilterToken, Filter, } from '../src/filter/filter-interfaces.js';

const repo = getRepository(entity);
var b = new FilterConsumerBridgeToKnexRequest(await dbNamesOf(repo.metadata, (x) => x), wrapIdentifier);
var b = new FilterConsumerBridgeToKnexRequest(await dbNamesOfWithForceSqlExpression(repo.metadata, (x) => x), wrapIdentifier);
b._addWhere = false;

@@ -187,3 +187,3 @@ await (await getRepositoryInternals(repo)._translateWhereToFilter(condition)).__applyToConsumer(b);

async init() {
const r = (await dbNamesOf(this.entity, (x) => x));
const r = (await dbNamesOfWithForceSqlExpression(this.entity, (x) => x));
return {

@@ -190,0 +190,0 @@ $dbNameOf: (f) => {

import { ObjectId, } from 'mongodb';
import { Filter } from './index.js';
import { dbNamesOf } from './src/filter/filter-consumer-bridge-to-sql-request.js';
import { dbNamesOf, dbNamesOfWithForceSqlExpression, } from './src/filter/filter-consumer-bridge-to-sql-request.js';
import { remult as remultContext } from './src/remult-proxy.js';

@@ -53,3 +53,3 @@ import { getRepository } from './src/remult3/RepositoryImplementation.js';

const repo = getRepository(entity);
var b = new FilterConsumerBridgeToMongo(await dbNamesOf(repo.metadata));
var b = new FilterConsumerBridgeToMongo(await dbNamesOfWithForceSqlExpression(repo.metadata));
b._addWhere = false;

@@ -56,0 +56,0 @@ await (await getRepositoryInternals(repo)._translateWhereToFilter(condition)).__applyToConsumer(b);

@@ -1,2 +0,2 @@

import { FilterConsumerBridgeToSqlRequest, dbNamesOf, isDbReadonly, } from '../filter/filter-consumer-bridge-to-sql-request.js';
import { FilterConsumerBridgeToSqlRequest, dbNamesOfWithForceSqlExpression, isDbReadonly, } from '../filter/filter-consumer-bridge-to-sql-request.js';
import { Filter, customDatabaseFilterToken, } from '../filter/filter-interfaces.js';

@@ -9,5 +9,17 @@ import { remult as defaultRemult } from '../remult-proxy.js';

import { isOfType } from '../isOfType.js';
// @dynamic
/**
* A DataProvider for Sql Databases
* @example
* const db = new SqlDatabase(new PostgresDataProvider(pgPool))
* @see [Connecting a Database](https://remult.dev/docs/quickstart#connecting-a-database)
*/
export class SqlDatabase {
sql;
/**
* Gets the SQL database from the data provider.
* @param dataProvider - The data provider.
* @returns The SQL database.
* @see [Direct Database Access](https://remult.dev/docs/running-sql-on-the-server)
*/
static getDb(dataProvider) {

@@ -20,8 +32,22 @@ const r = (dataProvider || defaultRemult.dataProvider);

}
/**
* Creates a new SQL command.
* @returns The SQL command.
* @see [Direct Database Access](https://remult.dev/docs/running-sql-on-the-server)
*/
createCommand() {
return new LogSQLCommand(this.sql.createCommand(), SqlDatabase.LogToConsole);
}
/**
* Executes a SQL command.
* @param sql - The SQL command.
* @returns The SQL result.
* @see [Direct Database Access](https://remult.dev/docs/running-sql-on-the-server)
*/
async execute(sql) {
return await this.createCommand().execute(sql);
}
/**
* Wraps an identifier with the database's identifier syntax.
*/
wrapIdentifier = (x) => x;

@@ -36,2 +62,7 @@ /* @internal*/

}
/**
* Gets the entity data provider.
* @param entity - The entity metadata.
* @returns The entity data provider.
*/
getEntityDataProvider(entity) {

@@ -50,3 +81,3 @@ if (!this.sql.supportsJsonColumnType) {

}
return new ActualSQLServerDataProvider(entity, this, async (dbName) => {
return new ActualSQLEntityDataProvider(entity, this, async (dbName) => {
if (this.createdEntities.indexOf(dbName.$entityName) < 0) {

@@ -58,2 +89,7 @@ this.createdEntities.push(dbName.$entityName);

}
/**
* Runs a transaction. Used internally by remult when transactions are required
* @param action - The action to run in the transaction.
* @returns The promise of the transaction.
*/
transaction(action) {

@@ -111,2 +147,7 @@ return this.sql.transaction(async (x) => {

}
/**
* Converts a filter to a raw SQL string.
* @see [Leveraging Database Capabilities with Raw SQL in Custom Filters](https://remult.dev/docs/running-sql-on-the-server#leveraging-entityfilter-for-sql-databases)
*/
static async filterToRaw(repo, condition, sqlCommand, dbNames, wrapIdentifier) {

@@ -117,3 +158,4 @@ if (!sqlCommand) {

const r = getRepository(repo);
var b = new FilterConsumerBridgeToSqlRequest(sqlCommand, dbNames || (await dbNamesOf(r.metadata, wrapIdentifier)));
var b = new FilterConsumerBridgeToSqlRequest(sqlCommand, dbNames ||
(await dbNamesOfWithForceSqlExpression(r.metadata, wrapIdentifier)));
b._addWhere = false;

@@ -131,2 +173,4 @@ await (await getRepositoryInternals(r)._translateWhereToFilter(condition)).__applyToConsumer(b);

* a `function` - to log all queries to the console as a custom format
* @example
* SqlDatabase.LogToConsole = (duration, query, args) => { console.log("be crazy ;)") }
*/

@@ -138,2 +182,8 @@ static LogToConsole = false;

static durationThreshold = 0;
/**
* Creates a new SQL database.
* @param sql - The SQL implementation.
* @example
* const db = new SqlDatabase(new PostgresDataProvider(pgPool))
*/
constructor(sql) {

@@ -218,3 +268,3 @@ this.sql = sql;

}
class ActualSQLServerDataProvider {
class ActualSQLEntityDataProvider {
entity;

@@ -232,3 +282,3 @@ sql;

async init() {
let dbNameProvider = await dbNamesOf(this.entity, (x) => this.sql.wrapIdentifier(x));
let dbNameProvider = await dbNamesOfWithForceSqlExpression(this.entity, (x) => this.sql.wrapIdentifier(x));
await this.iAmUsed(dbNameProvider);

@@ -235,0 +285,0 @@ return dbNameProvider;

@@ -193,2 +193,8 @@ import { SqlDatabase } from '../data-providers/sql-database.js';

export async function dbNamesOf(repo, wrapIdentifierOrOptions) {
return internalDbNamesOf(repo, wrapIdentifierOrOptions);
}
export async function dbNamesOfWithForceSqlExpression(repo, wrapIdentifierOrOptions) {
return internalDbNamesOf(repo, wrapIdentifierOrOptions, true);
}
async function internalDbNamesOf(repo, wrapIdentifierOrOptions, forceSqlExpression = false) {
let options = typeof wrapIdentifierOrOptions === 'function'

@@ -217,3 +223,3 @@ ? { wrapIdentifier: wrapIdentifierOrOptions }

for (const field of meta.fields) {
let r = await fieldDbName(field, meta, options.wrapIdentifier);
let r = await fieldDbName(field, meta, options.wrapIdentifier, forceSqlExpression);
if (!field.options.sqlExpression)

@@ -247,3 +253,4 @@ if (typeof options.tableName === 'string')

}
export async function fieldDbName(f, meta, wrapIdentifier = (x) => x) {
const sqlExpressionInProgressKey = Symbol.for(`sqlExpressionInProgressKey`);
export async function fieldDbName(f, meta, wrapIdentifier = (x) => x, forceSqlExpression = false) {
try {

@@ -253,10 +260,12 @@ if (f.options.sqlExpression) {

if (typeof f.options.sqlExpression === 'function') {
const prev = f.options.sqlExpression;
if (f[sqlExpressionInProgressKey] && !forceSqlExpression) {
return "recursive sqlExpression call for field '" + f.key + "'. ";
}
try {
f.options.sqlExpression =
"recursive sqlExpression call for field '" + f.key + "'. ";
result = await prev(meta);
f[sqlExpressionInProgressKey] = true;
result = await f.options.sqlExpression(meta);
f.options.sqlExpression = () => result;
}
finally {
delete f[sqlExpressionInProgressKey];
}

@@ -276,3 +285,3 @@ }

if (fInfo)
return fieldDbName(fInfo, meta, wrapIdentifier);
return fieldDbName(fInfo, meta, wrapIdentifier, forceSqlExpression);
}

@@ -279,0 +288,0 @@ return wrapIdentifier(f.dbName);

export const flags = {
error500RetryCount: 4,
};
//p1 - fix query docs to also explain how it can be used for infinite scroll and pagination.
//y1 - 'test expression columns without aliases'

@@ -11,2 +12,3 @@ //p1 - see if I can fix the no alias problem in selects

//p1 - explain the benefits of changing the default provider for testing in docs.
//p1 - fix sqlite to support alter table when adding a column with ensure schema = on
//p1 - fix app custom filters example for multiple filters.

@@ -13,0 +15,0 @@ //p1 - add not!!!!

{
"name": "remult",
"version": "0.26.18",
"version": "0.26.19-next.0",
"description": "A CRUD framework for full-stack TypeScript",

@@ -5,0 +5,0 @@ "homepage": "https://remult.dev",

@@ -160,3 +160,3 @@ "use strict";

_a = FilterConsumerBridgeToKnexRequest.bind;
return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_2.dbNamesOf)(repo.metadata, function (x) { return x; })];
return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOfWithForceSqlExpression)(repo.metadata, function (x) { return x; })];
case 1:

@@ -314,3 +314,3 @@ b = new (_a.apply(FilterConsumerBridgeToKnexRequest, [void 0, _b.sent(), wrapIdentifier]))();

switch (_a.label) {
case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_2.dbNamesOf)(this.entity, function (x) { return x; })];
case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOfWithForceSqlExpression)(this.entity, function (x) { return x; })];
case 1:

@@ -317,0 +317,0 @@ r = (_a.sent());

@@ -81,3 +81,3 @@ "use strict";

_a = FilterConsumerBridgeToMongo.bind;
return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(repo.metadata)];
return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOfWithForceSqlExpression)(repo.metadata)];
case 1:

@@ -84,0 +84,0 @@ b = new (_a.apply(FilterConsumerBridgeToMongo, [void 0, _b.sent()]))();

@@ -7,10 +7,47 @@ import type { DataProvider, EntityDataProvider } from '../data-interfaces.js';

import type { CanBuildMigrations, MigrationBuilder, MigrationCode } from '../../migrations/migration-types.js';
/**
* A DataProvider for Sql Databases
* @example
* const db = new SqlDatabase(new PostgresDataProvider(pgPool))
* @see [Connecting a Database](https://remult.dev/docs/quickstart#connecting-a-database)
*/
export declare class SqlDatabase implements DataProvider, HasWrapIdentifier, CanBuildMigrations, SqlCommandFactory {
private sql;
/**
* Gets the SQL database from the data provider.
* @param dataProvider - The data provider.
* @returns The SQL database.
* @see [Direct Database Access](https://remult.dev/docs/running-sql-on-the-server)
*/
static getDb(dataProvider?: DataProvider): SqlDatabase;
/**
* Creates a new SQL command.
* @returns The SQL command.
* @see [Direct Database Access](https://remult.dev/docs/running-sql-on-the-server)
*/
createCommand(): SqlCommand;
/**
* Executes a SQL command.
* @param sql - The SQL command.
* @returns The SQL result.
* @see [Direct Database Access](https://remult.dev/docs/running-sql-on-the-server)
*/
execute(sql: string): Promise<SqlResult>;
/**
* Wraps an identifier with the database's identifier syntax.
*/
wrapIdentifier: (name: string) => string;
ensureSchema(entities: EntityMetadata<any>[]): Promise<void>;
/**
* Gets the entity data provider.
* @param entity - The entity metadata.
* @returns The entity data provider.
*/
getEntityDataProvider(entity: EntityMetadata): EntityDataProvider;
/**
* Runs a transaction. Used internally by remult when transactions are required
* @param action - The action to run in the transaction.
* @returns The promise of the transaction.
*/
transaction(action: (dataProvider: DataProvider) => Promise<void>): Promise<void>;

@@ -28,2 +65,7 @@ /**

static rawFilter(build: CustomSqlFilterBuilderFunction): EntityFilter<any>;
/**
* Converts a filter to a raw SQL string.
* @see [Leveraging Database Capabilities with Raw SQL in Custom Filters](https://remult.dev/docs/running-sql-on-the-server#leveraging-entityfilter-for-sql-databases)
*/
static filterToRaw<entityType>(repo: RepositoryOverloads<entityType>, condition: EntityFilter<entityType>, sqlCommand?: SqlCommandWithParameters, dbNames?: EntityDbNamesBase, wrapIdentifier?: (name: string) => string): Promise<string>;

@@ -38,2 +80,4 @@ /**

* a `function` - to log all queries to the console as a custom format
* @example
* SqlDatabase.LogToConsole = (duration, query, args) => { console.log("be crazy ;)") }
*/

@@ -45,2 +89,8 @@ static LogToConsole: boolean | 'oneLiner' | ((duration: number, query: string, args: Record<string, any>) => void);

static durationThreshold: number;
/**
* Creates a new SQL database.
* @param sql - The SQL implementation.
* @example
* const db = new SqlDatabase(new PostgresDataProvider(pgPool))
*/
constructor(sql: SqlImplementation);

@@ -47,0 +97,0 @@ provideMigrationBuilder: (builder: MigrationCode) => MigrationBuilder;

@@ -13,6 +13,21 @@ "use strict";

var isOfType_js_1 = require("../isOfType.js");
// @dynamic
/**
* A DataProvider for Sql Databases
* @example
* const db = new SqlDatabase(new PostgresDataProvider(pgPool))
* @see [Connecting a Database](https://remult.dev/docs/quickstart#connecting-a-database)
*/
var SqlDatabase = /** @class */ (function () {
/**
* Creates a new SQL database.
* @param sql - The SQL implementation.
* @example
* const db = new SqlDatabase(new PostgresDataProvider(pgPool))
*/
function SqlDatabase(sql) {
this.sql = sql;
/**
* Wraps an identifier with the database's identifier syntax.
*/
this.wrapIdentifier = function (x) { return x; };

@@ -28,2 +43,8 @@ this.createdEntities = [];

}
/**
* Gets the SQL database from the data provider.
* @param dataProvider - The data provider.
* @returns The SQL database.
* @see [Direct Database Access](https://remult.dev/docs/running-sql-on-the-server)
*/
SqlDatabase.getDb = function (dataProvider) {

@@ -36,5 +57,16 @@ var r = (dataProvider || remult_proxy_js_1.remult.dataProvider);

};
/**
* Creates a new SQL command.
* @returns The SQL command.
* @see [Direct Database Access](https://remult.dev/docs/running-sql-on-the-server)
*/
SqlDatabase.prototype.createCommand = function () {
return new LogSQLCommand(this.sql.createCommand(), SqlDatabase.LogToConsole);
};
/**
* Executes a SQL command.
* @param sql - The SQL command.
* @returns The SQL result.
* @see [Direct Database Access](https://remult.dev/docs/running-sql-on-the-server)
*/
SqlDatabase.prototype.execute = function (sql) {

@@ -69,2 +101,7 @@ return tslib_1.__awaiter(this, void 0, void 0, function () {

};
/**
* Gets the entity data provider.
* @param entity - The entity metadata.
* @returns The entity data provider.
*/
SqlDatabase.prototype.getEntityDataProvider = function (entity) {

@@ -91,3 +128,3 @@ var e_1, _a;

}
return new ActualSQLServerDataProvider(entity, this, function (dbName) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
return new ActualSQLEntityDataProvider(entity, this, function (dbName) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {

@@ -107,2 +144,7 @@ switch (_a.label) {

};
/**
* Runs a transaction. Used internally by remult when transactions are required
* @param action - The action to run in the transaction.
* @returns The promise of the transaction.
*/
SqlDatabase.prototype.transaction = function (action) {

@@ -178,2 +220,7 @@ var _this = this;

};
/**
* Converts a filter to a raw SQL string.
* @see [Leveraging Database Capabilities with Raw SQL in Custom Filters](https://remult.dev/docs/running-sql-on-the-server#leveraging-entityfilter-for-sql-databases)
*/
SqlDatabase.filterToRaw = function (repo, condition, sqlCommand, dbNames, wrapIdentifier) {

@@ -193,3 +240,3 @@ return tslib_1.__awaiter(this, void 0, void 0, function () {

if (_c) return [3 /*break*/, 2];
return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(r.metadata, wrapIdentifier)];
return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOfWithForceSqlExpression)(r.metadata, wrapIdentifier)];
case 1:

@@ -219,2 +266,4 @@ _c = (_d.sent());

* a `function` - to log all queries to the console as a custom format
* @example
* SqlDatabase.LogToConsole = (duration, query, args) => { console.log("be crazy ;)") }
*/

@@ -303,4 +352,4 @@ SqlDatabase.LogToConsole = false;

}());
var ActualSQLServerDataProvider = /** @class */ (function () {
function ActualSQLServerDataProvider(entity, sql, iAmUsed, strategy) {
var ActualSQLEntityDataProvider = /** @class */ (function () {
function ActualSQLEntityDataProvider(entity, sql, iAmUsed, strategy) {
this.entity = entity;

@@ -311,3 +360,3 @@ this.sql = sql;

}
ActualSQLServerDataProvider.prototype.init = function () {
ActualSQLEntityDataProvider.prototype.init = function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {

@@ -318,3 +367,3 @@ var dbNameProvider;

switch (_a.label) {
case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(this.entity, function (x) {
case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOfWithForceSqlExpression)(this.entity, function (x) {
return _this.sql.wrapIdentifier(x);

@@ -332,3 +381,3 @@ })];

};
ActualSQLServerDataProvider.prototype.count = function (where) {
ActualSQLEntityDataProvider.prototype.count = function (where) {
return tslib_1.__awaiter(this, void 0, void 0, function () {

@@ -358,3 +407,3 @@ var e, select, r, wc, _a;

};
ActualSQLServerDataProvider.prototype.find = function (options) {
ActualSQLEntityDataProvider.prototype.find = function (options) {
return tslib_1.__awaiter(this, void 0, void 0, function () {

@@ -453,3 +502,3 @@ var e, _a, colKeys, select, r, where, _b, first, segs, _c, _d, s, segs_1, segs_1_1, c, page;

};
ActualSQLServerDataProvider.prototype.buildResultRow = function (colKeys, y, r) {
ActualSQLEntityDataProvider.prototype.buildResultRow = function (colKeys, y, r) {
var result = {};

@@ -467,3 +516,3 @@ for (var index = 0; index < colKeys.length; index++) {

};
ActualSQLServerDataProvider.prototype.buildSelect = function (e) {
ActualSQLEntityDataProvider.prototype.buildSelect = function (e) {
var e_4, _a;

@@ -496,3 +545,3 @@ var select = '';

};
ActualSQLServerDataProvider.prototype.update = function (id, data) {
ActualSQLEntityDataProvider.prototype.update = function (id, data) {
return tslib_1.__awaiter(this, void 0, void 0, function () {

@@ -567,3 +616,3 @@ var e, r, statement, added, _a, _b, x, v, idFilter, f, _c, _d, colKeys, select, returning;

};
ActualSQLServerDataProvider.prototype.delete = function (id) {
ActualSQLEntityDataProvider.prototype.delete = function (id) {
return tslib_1.__awaiter(this, void 0, void 0, function () {

@@ -593,3 +642,3 @@ var e, r, f, statement, _a;

};
ActualSQLServerDataProvider.prototype.insert = function (data) {
ActualSQLEntityDataProvider.prototype.insert = function (data) {
return tslib_1.__awaiter(this, void 0, void 0, function () {

@@ -665,4 +714,4 @@ var e, r, cols, vals, added, _a, _b, x, v, statement, _c, colKeys, select;

};
ActualSQLServerDataProvider.LogToConsole = false;
return ActualSQLServerDataProvider;
ActualSQLEntityDataProvider.LogToConsole = false;
return ActualSQLEntityDataProvider;
}());

@@ -669,0 +718,0 @@ var myDummySQLCommand = /** @class */ (function () {

@@ -83,3 +83,4 @@ import type { FieldMetadata } from '../column-interfaces.js';

export declare function dbNamesOf<entityType>(repo: EntityMetadataOverloads<entityType>, wrapIdentifierOrOptions?: ((name: string) => string) | dbNamesOfOptions): Promise<EntityDbNames<entityType>>;
export declare function dbNamesOfWithForceSqlExpression<entityType>(repo: EntityMetadataOverloads<entityType>, wrapIdentifierOrOptions?: ((name: string) => string) | dbNamesOfOptions): Promise<EntityDbNames<entityType>>;
export declare function entityDbName(metadata: EntityMetadata, wrapIdentifier?: (name: string) => string): Promise<string>;
export declare function fieldDbName(f: FieldMetadata, meta: EntityMetadata, wrapIdentifier?: (name: string) => string): Promise<string>;
export declare function fieldDbName(f: FieldMetadata, meta: EntityMetadata, wrapIdentifier?: (name: string) => string, forceSqlExpression?: boolean): Promise<string>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fieldDbName = exports.entityDbName = exports.dbNamesOf = exports.shouldCreateEntity = exports.shouldNotCreateField = exports.isDbReadonly = exports.CustomSqlFilterBuilder = exports.FilterConsumerBridgeToSqlRequest = void 0;
exports.fieldDbName = exports.entityDbName = exports.dbNamesOfWithForceSqlExpression = exports.dbNamesOf = exports.shouldCreateEntity = exports.shouldNotCreateField = exports.isDbReadonly = exports.CustomSqlFilterBuilder = exports.FilterConsumerBridgeToSqlRequest = void 0;
var tslib_1 = require("tslib");

@@ -301,2 +301,19 @@ var sql_database_js_1 = require("../data-providers/sql-database.js");

return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
return [2 /*return*/, internalDbNamesOf(repo, wrapIdentifierOrOptions)];
});
});
}
exports.dbNamesOf = dbNamesOf;
function dbNamesOfWithForceSqlExpression(repo, wrapIdentifierOrOptions) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
return [2 /*return*/, internalDbNamesOf(repo, wrapIdentifierOrOptions, true)];
});
});
}
exports.dbNamesOfWithForceSqlExpression = dbNamesOfWithForceSqlExpression;
function internalDbNamesOf(repo, wrapIdentifierOrOptions, forceSqlExpression) {
if (forceSqlExpression === void 0) { forceSqlExpression = false; }
return tslib_1.__awaiter(this, void 0, void 0, function () {
var options, meta, result, _a, _b, field, r, e_3_1;

@@ -339,3 +356,3 @@ var _c, e_3, _d;

field = _b.value;
return [4 /*yield*/, fieldDbName(field, meta, options.wrapIdentifier)];
return [4 /*yield*/, fieldDbName(field, meta, options.wrapIdentifier, forceSqlExpression)];
case 4:

@@ -370,3 +387,2 @@ r = _e.sent();

}
exports.dbNamesOf = dbNamesOf;
function entityDbName(metadata, wrapIdentifier) {

@@ -401,6 +417,8 @@ if (wrapIdentifier === void 0) { wrapIdentifier = function (x) { return x; }; }

exports.entityDbName = entityDbName;
function fieldDbName(f, meta, wrapIdentifier) {
var sqlExpressionInProgressKey = Symbol.for("sqlExpressionInProgressKey");
function fieldDbName(f, meta, wrapIdentifier, forceSqlExpression) {
if (wrapIdentifier === void 0) { wrapIdentifier = function (x) { return x; }; }
if (forceSqlExpression === void 0) { forceSqlExpression = false; }
return tslib_1.__awaiter(this, void 0, void 0, function () {
var result_1, prev, rel, field, fInfo;
var result_1, rel, field, fInfo;
return tslib_1.__generator(this, function (_a) {

@@ -412,9 +430,10 @@ switch (_a.label) {

if (!(typeof f.options.sqlExpression === 'function')) return [3 /*break*/, 5];
prev = f.options.sqlExpression;
if (f[sqlExpressionInProgressKey] && !forceSqlExpression) {
return [2 /*return*/, "recursive sqlExpression call for field '" + f.key + "'. "];
}
_a.label = 1;
case 1:
_a.trys.push([1, , 3, 4]);
f.options.sqlExpression =
"recursive sqlExpression call for field '" + f.key + "'. ";
return [4 /*yield*/, prev(meta)];
f[sqlExpressionInProgressKey] = true;
return [4 /*yield*/, f.options.sqlExpression(meta)];
case 2:

@@ -424,3 +443,5 @@ result_1 = _a.sent();

return [3 /*break*/, 4];
case 3: return [7 /*endfinally*/];
case 3:
delete f[sqlExpressionInProgressKey];
return [7 /*endfinally*/];
case 4: return [3 /*break*/, 6];

@@ -441,3 +462,3 @@ case 5:

if (fInfo)
return [2 /*return*/, fieldDbName(fInfo, meta, wrapIdentifier)];
return [2 /*return*/, fieldDbName(fInfo, meta, wrapIdentifier, forceSqlExpression)];
}

@@ -444,0 +465,0 @@ return [2 /*return*/, wrapIdentifier(f.dbName)];

@@ -288,2 +288,15 @@ import type { ErrorInfo, FieldOptions } from '../../index.js';

* }
* @example
* const query = taskRepo.query({
* where: { completed: false },
* pageSize: 100,
* })
* const count = await query.count()
* console.log('Paged: ' + count / 100)
* let paginator = await query.paginator()
* console.log(paginator.items.length)
* if (paginator.hasNextPage) {
* paginator = await paginator.nextPage()
* console.log(paginator.items.length)
* }
* */

@@ -600,3 +613,18 @@ query(options?: QueryOptions<entityType>): QueryResult<entityType>;

}
/** An interface used to paginating using the `query` method in the `Repository` object */
/** An interface used to paginating using the `query` method in the `Repository` object
* @example
* @example
* const query = taskRepo.query({
* where: { completed: false },
* pageSize: 100,
* })
* const count = await query.count()
* console.log('Paged: ' + count / 100)
* let paginator = await query.paginator()
* console.log(paginator.items.length)
* if (paginator.hasNextPage) {
* paginator = await paginator.nextPage()
* console.log(paginator.items.length)
* }
*/
export interface Paginator<entityType> {

@@ -603,0 +631,0 @@ /** the items in the current page */

@@ -7,2 +7,3 @@ "use strict";

};
//p1 - fix query docs to also explain how it can be used for infinite scroll and pagination.
//y1 - 'test expression columns without aliases'

@@ -15,2 +16,3 @@ //p1 - see if I can fix the no alias problem in selects

//p1 - explain the benefits of changing the default provider for testing in docs.
//p1 - fix sqlite to support alter table when adding a column with ensure schema = on
//p1 - fix app custom filters example for multiple filters.

@@ -17,0 +19,0 @@ //p1 - add not!!!!

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc