New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

expo-sqlite-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expo-sqlite-wrapper - npm Package Compare versions

Comparing version 1.3.7 to 1.3.8

3

dist/BulkSave.d.ts
import { IBaseModule, IDatabase } from "./expo.sql.wrapper.types";
import * as SQLite from 'expo-sqlite';
export default class BulkSave<T, D extends string> {
private quries;
quries: SQLite.Query[];
private dbContext;

@@ -5,0 +6,0 @@ private keys;

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

const itemArray = Array.isArray(items) ? items : [items];
const table = this.dbContext.tables.find(x => x.tableName == this.tableName);
itemArray.forEach(item => {

@@ -26,2 +27,3 @@ const q = { sql: `INSERT INTO ${this.tableName} (`, args: [] };

var _a;
const column = table === null || table === void 0 ? void 0 : table.props.find(x => x.columnName == k && x.encryptionKey);
let v = (_a = item[k]) !== null && _a !== void 0 ? _a : null;

@@ -32,2 +34,4 @@ if ((0, SqlQueryBuilder_1.isDate)(v))

v = v === true ? 1 : 0;
if (column)
v = (0, SqlQueryBuilder_1.encrypt)(v, column.encryptionKey);
q.args.push(v);

@@ -41,2 +45,3 @@ });

const itemArray = Array.isArray(items) ? items : [items];
const table = this.dbContext.tables.find(x => x.tableName == this.tableName);
itemArray.forEach(item => {

@@ -50,2 +55,3 @@ const q = { sql: `UPDATE ${this.tableName} SET `, args: [] };

var _a;
const column = table === null || table === void 0 ? void 0 : table.props.find(x => x.columnName == k && x.encryptionKey);
let v = (_a = item[k]) !== null && _a !== void 0 ? _a : null;

@@ -56,2 +62,4 @@ if ((0, SqlQueryBuilder_1.isDate)(v))

v = v === true ? 1 : 0;
if (column)
v = (0, SqlQueryBuilder_1.encrypt)(v, column.encryptionKey);
q.args.push(v);

@@ -58,0 +66,0 @@ });

import * as SqlLite from 'expo-sqlite';
import { TableBuilder } from './TableStructor';
import BulkSave from './BulkSave';

@@ -91,2 +92,5 @@ export declare type ColumnType = 'Number' | 'String' | 'Decimal' | 'Boolean' | "DateTime";

export declare type StringValue = string | undefined;
export declare type IDataBaseExtender<D extends string> = {
tables: TableBuilder<any, D>[];
} & IDatabase<D>;
export interface IChildQueryLoader<T, B, D extends string> {

@@ -93,0 +97,0 @@ With: <E>(columnName: NonFunctionPropertyNames<E>) => IChildQueryLoader<T, B, D>;

@@ -1,8 +0,5 @@

import { NonFunctionPropertyNames, IBaseModule, SingleValue, ArrayValue, NumberValue, IChildQueryLoader, IChildLoader, IQuaryResult, IQuery, IQueryResultItem, IDatabase, StringValue } from './expo.sql.wrapper.types';
import { IDataBaseExtender, NonFunctionPropertyNames, IBaseModule, SingleValue, ArrayValue, NumberValue, IChildQueryLoader, IChildLoader, IQuaryResult, IQuery, IQueryResultItem, IDatabase, StringValue } from './expo.sql.wrapper.types';
import { TableBuilder } from './TableStructor';
export declare const CreateSqlInstaceOfType: (prototype: any, item: any) => any;
export declare const createQueryResultType: <T, D extends string>(item: any, database: IDatabase<D>, children?: IChildLoader<D>[]) => Promise<IQueryResultItem<T, D>>;
declare type IDataBaseExtender<D extends string> = {
tables: TableBuilder<any, D>[];
} & IDatabase<D>;
export declare const translateToSqliteValue: (v: any) => any;

@@ -67,2 +64,1 @@ export declare const translateAndEncrypt: (v: any, database: IDataBaseExtender<string>, tableName: string, column?: string) => any;

}
export {};

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

const SqlQueryBuilder_1 = require("../SqlQueryBuilder");
const BulkSave_1 = __importDefault(require("../BulkSave"));
const TableStructor_1 = __importDefault(require("../TableStructor"));

@@ -27,2 +28,3 @@ const database = {

mocha_1.default.describe("readEncryption", function () {
console.log("readEncryption");
var q = new SqlQueryBuilder_1.Query("Test", database);

@@ -46,2 +48,14 @@ q.Column("password").EqualTo("test").AND().Column("name").EqualTo("hey").Limit(100).OrderByAsc("name").getQueryResult("SELECT").sql.trim().should.eql("SELECT * FROM Test WHERE password = ? AND name = ? Limit 100 Order By name ASC");

});
mocha_1.default.describe("bulkSaveWithEncryptionsInsert", function () {
console.log("bulkSaveWithEncryptionsInsert");
const b = new BulkSave_1.default(database, ["name", "password"], "Test").insert(item);
b.quries[0].args[1].should.eql("#dbEncrypted&R9e01Yx38fEBCU6PBNsWZQ==");
b.quries[0].args[0].should.eql(item.name);
});
mocha_1.default.describe("bulkSaveWithEncryptionsUpdate", function () {
console.log("bulkSaveWithEncryptionsUpdate");
const b = new BulkSave_1.default(database, ["name", "password"], "Test").update(item);
b.quries[0].args[1].should.eql("#dbEncrypted&R9e01Yx38fEBCU6PBNsWZQ==");
b.quries[0].args[0].should.eql(item.name);
});
mocha_1.default.describe("DeleteWthLimit", function () {

@@ -48,0 +62,0 @@ var q = new SqlQueryBuilder_1.Query("Test", database);

{
"name": "expo-sqlite-wrapper",
"version": "1.3.7",
"version": "1.3.8",
"description": "This is an ORM, build around expo-sqlite. It will make operation like UPDATE,SELECT AND INSERT a lot easier to handle",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -1,12 +0,12 @@

import { IBaseModule, IDatabase } from "./expo.sql.wrapper.types";
import { isDate } from "./SqlQueryBuilder";
import { IBaseModule, IDatabase, IDataBaseExtender } from "./expo.sql.wrapper.types";
import { encrypt, isDate, oEncypt } from "./SqlQueryBuilder";
import * as SQLite from 'expo-sqlite';
export default class BulkSave<T, D extends string> {
private quries: SQLite.Query[];
private dbContext: IDatabase<D>;
quries: SQLite.Query[];
private dbContext: IDataBaseExtender<D>;
private keys: string[];
private tableName: D;
constructor(dbContext: IDatabase<D>, keys: string[], tableName: D) {
this.dbContext = dbContext;
this.dbContext = dbContext as any;
this.keys = keys;

@@ -19,2 +19,3 @@ this.tableName = tableName;

const itemArray = Array.isArray(items) ? items : [items];
const table = this.dbContext.tables.find(x => x.tableName == this.tableName);
itemArray.forEach(item => {

@@ -32,2 +33,3 @@ const q = { sql: `INSERT INTO ${this.tableName} (`, args: [] };

this.keys.forEach((k: string, i) => {
const column = table?.props.find(x => x.columnName == k && x.encryptionKey);
let v = (item as any)[k] ?? null;

@@ -38,2 +40,4 @@ if (isDate(v))

v = v === true ? 1 : 0;
if (column)
v = encrypt(v, column.encryptionKey);
q.args.push(v);

@@ -49,2 +53,3 @@ });

const itemArray = Array.isArray(items) ? items : [items];
const table = this.dbContext.tables.find(x => x.tableName == this.tableName);
itemArray.forEach(item => {

@@ -57,2 +62,3 @@ const q = { sql: `UPDATE ${this.tableName} SET `, args: [] };

this.keys.forEach((k: string, i) => {
const column = table?.props.find(x => x.columnName == k && x.encryptionKey);
let v = (item as any)[k] ?? null;

@@ -63,2 +69,4 @@ if (isDate(v))

v = v === true ? 1 : 0;
if (column)
v = encrypt(v, column.encryptionKey);
q.args.push(v);

@@ -80,2 +88,3 @@ });

}

@@ -82,0 +91,0 @@ async execute() {

import * as SqlLite from 'expo-sqlite'
import { TableBuilder } from './TableStructor';
import BulkSave from './BulkSave';

@@ -99,2 +100,5 @@

export type IDataBaseExtender<D extends string> = {
tables: TableBuilder<any, D>[];
} & IDatabase<D>

@@ -101,0 +105,0 @@ export interface IChildQueryLoader<T, B, D extends string> {

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

import { NonFunctionPropertyNames, IBaseModule, SingleValue, ArrayValue, NumberValue, IChildQueryLoader, IChildLoader, IQuaryResult, IQuery, IQueryResultItem, IDatabase, Param, StringValue } from './expo.sql.wrapper.types'
import {IDataBaseExtender, NonFunctionPropertyNames, IBaseModule, SingleValue, ArrayValue, NumberValue, IChildQueryLoader, IChildLoader, IQuaryResult, IQuery, IQueryResultItem, IDatabase, Param, StringValue } from './expo.sql.wrapper.types'
import { TableBuilder } from './TableStructor';

@@ -58,5 +58,2 @@ import crypto from 'crypto-js'

type IDataBaseExtender<D extends string> = {
tables: TableBuilder<any, D>[];
} & IDatabase<D>

@@ -63,0 +60,0 @@ export const translateToSqliteValue = (v: any) => {

import 'should'
import mocha from 'mocha'
import { createQueryResultType, Query, jsonToSqlite, encrypt, decrypt } from '../SqlQueryBuilder';
import BulkSave from '../BulkSave';
import TableBuilder from '../TableStructor'

@@ -33,2 +34,3 @@ import crypto from 'crypto-js'

mocha.describe("readEncryption", function () {
console.log("readEncryption")
var q = new Query<Test, TableName>("Test", database);

@@ -40,2 +42,4 @@ q.Column("password").EqualTo("test").AND().Column("name").EqualTo("hey").Limit(100).OrderByAsc("name").getQueryResult("SELECT").sql.trim().should.eql("SELECT * FROM Test WHERE password = ? AND name = ? Limit 100 Order By name ASC")

mocha.describe("JsonToSql", function () {

@@ -57,2 +61,17 @@

mocha.describe("bulkSaveWithEncryptionsInsert", function () {
console.log("bulkSaveWithEncryptionsInsert")
const b = new BulkSave<Test, TableName>(database, ["name", "password"], "Test").insert(item as any);
b.quries[0].args[1].should.eql("#dbEncrypted&R9e01Yx38fEBCU6PBNsWZQ==")
b.quries[0].args[0].should.eql(item.name)
});
mocha.describe("bulkSaveWithEncryptionsUpdate", function () {
console.log("bulkSaveWithEncryptionsUpdate");
const b = new BulkSave<Test, TableName>(database, ["name", "password"], "Test").update(item as any);
b.quries[0].args[1].should.eql("#dbEncrypted&R9e01Yx38fEBCU6PBNsWZQ==");
b.quries[0].args[0].should.eql(item.name);
});
mocha.describe("DeleteWthLimit", function () {

@@ -59,0 +78,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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