@nativescript-community/sqlite
Advanced tools
Comparing version
{ | ||
"name": "@nativescript-community/sqlite", | ||
"version": "3.4.2", | ||
"version": "3.5.0", | ||
"description": "SQLite for Nativescript", | ||
@@ -41,3 +41,3 @@ "main": "sqlite", | ||
"@nano-sql/core": "^2.3.7", | ||
"@nativescript-community/typeorm": "0.2.28-1" | ||
"typeorm": "^0.3.17" | ||
}, | ||
@@ -47,3 +47,3 @@ "dependencies": { | ||
}, | ||
"gitHead": "f7c54e1965d61a17d1037facc81f88785c52908f" | ||
"gitHead": "617ba606556034bc1232bf89f946b31e7fd25104" | ||
} |
@@ -42,2 +42,3 @@ <!-- ⚠️ This README has been generated from the file(s) "blueprint.md" ⚠️--> | ||
* [Usage](#usage) | ||
* [Platforms sqlite versions](#platforms-sqlite-versions) | ||
@@ -74,1 +75,10 @@ | ||
``` | ||
[](#platforms-sqlite-versions) | ||
## Platforms sqlite versions | ||
* [Android](https://stackoverflow.com/a/4377116) | ||
* [iOS](https://github.com/yapstudios/YapDatabase/wiki/SQLite-version-(bundled-with-OS)) | ||
@@ -1,8 +0,8 @@ | ||
export declare type SqliteParam = null | number | string | ArrayBuffer | any; | ||
export declare type SqliteParams = SqliteParam | SqliteParam[]; | ||
export type SqliteParam = null | number | string | ArrayBuffer | any; | ||
export type SqliteParams = SqliteParam | SqliteParam[]; | ||
export interface SqliteRow { | ||
[name: string]: SqliteParam; | ||
} | ||
export declare type Db = any; | ||
export declare type SqliteUpgrade = (db: Db) => void; | ||
export type Db = any; | ||
export type SqliteUpgrade = (db: Db) => void; | ||
export interface SQLiteDatabase { | ||
@@ -9,0 +9,0 @@ getVersion(): any; |
@@ -370,3 +370,3 @@ import { paramsToStringArray, throwError } from './sqlite.common'; | ||
} | ||
throwError(`transaction: ${e}`); | ||
throwError(e); | ||
return null; | ||
@@ -430,10 +430,20 @@ } | ||
let res; | ||
if (!this._isInTransaction) { | ||
this._isInTransaction = true; | ||
res = transactionRaw(this.db, action, true); | ||
this._isInTransaction = false; | ||
let shouldFinishTransaction = false; | ||
try { | ||
if (!this._isInTransaction) { | ||
this._isInTransaction = shouldFinishTransaction = true; | ||
res = await transactionRaw(this.db, action, true); | ||
} | ||
else { | ||
res = await transactionRaw(this.db, action, false); | ||
} | ||
} | ||
else { | ||
res = transactionRaw(this.db, action, false); | ||
catch (error) { | ||
throw error; | ||
} | ||
finally { | ||
if (shouldFinishTransaction) { | ||
this._isInTransaction = false; | ||
} | ||
} | ||
return res; | ||
@@ -440,0 +450,0 @@ } |
@@ -1,2 +0,4 @@ | ||
import { BaseConnectionOptions } from '@nativescript-community/typeorm/browser/connection/BaseConnectionOptions'; | ||
import { BaseDataSourceOptions } from 'typeorm/browser/data-source/BaseDataSourceOptions'; | ||
export * from './NativescriptDriver'; | ||
export * from './NativescriptQueryRunner'; | ||
export declare function installMixins(): void; | ||
@@ -6,3 +8,3 @@ /** | ||
*/ | ||
export interface NativescriptConnectionOptions extends BaseConnectionOptions { | ||
export interface NativescriptConnectionOptions extends BaseDataSourceOptions { | ||
/** | ||
@@ -9,0 +11,0 @@ * Database type. |
@@ -1,3 +0,5 @@ | ||
import { Connection } from '@nativescript-community/typeorm/browser/connection/Connection'; | ||
import { DataSource } from 'typeorm/browser'; | ||
import { NativescriptDriver } from './NativescriptDriver'; | ||
export * from './NativescriptDriver'; | ||
export * from './NativescriptQueryRunner'; | ||
let installed = false; | ||
@@ -9,6 +11,10 @@ export function installMixins() { | ||
installed = true; | ||
const DriverFactory = require('@nativescript-community/typeorm/browser/driver/DriverFactory').DriverFactory; | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const DriverFactory = require('typeorm/browser/driver/DriverFactory').DriverFactory; | ||
const oldFunc = DriverFactory.prototype.create; | ||
DriverFactory.prototype.create = function (connection) { | ||
const { type } = connection.options; | ||
if (type === '@nativescript-community/sqlite') { | ||
console.warn('"@nativescript-community/sqlite" is not recognized as a valid sqlite driver by typeorm and will break some SQL queries. Please use "nativescript" instead.'); | ||
} | ||
switch (type) { | ||
@@ -15,0 +21,0 @@ case 'nativescript': |
@@ -1,5 +0,3 @@ | ||
import { Connection } from '@nativescript-community/typeorm/browser/connection/Connection'; | ||
import { AbstractSqliteDriver } from '@nativescript-community/typeorm/browser/driver/sqlite-abstract/AbstractSqliteDriver'; | ||
import { ColumnType } from '@nativescript-community/typeorm/browser/driver/types/ColumnTypes'; | ||
import { QueryRunner } from '@nativescript-community/typeorm/browser/query-runner/QueryRunner'; | ||
import { ColumnType, DataSource, QueryRunner } from 'typeorm/browser'; | ||
import { AbstractSqliteDriver } from 'typeorm/browser/driver/sqlite-abstract/AbstractSqliteDriver'; | ||
import * as NSQlite from '../sqlite'; | ||
@@ -21,3 +19,3 @@ import { NativescriptConnectionOptions } from './index'; | ||
driver: any; | ||
constructor(connection: Connection); | ||
constructor(connection: DataSource); | ||
/** | ||
@@ -24,0 +22,0 @@ * Closes connection with database. |
@@ -1,5 +0,3 @@ | ||
import { Connection } from '@nativescript-community/typeorm/browser/connection/Connection'; | ||
import { AbstractSqliteDriver } from '@nativescript-community/typeorm/browser/driver/sqlite-abstract/AbstractSqliteDriver'; | ||
import { DriverOptionNotSetError } from '@nativescript-community/typeorm/browser/error/DriverOptionNotSetError'; | ||
import { DriverPackageNotInstalledError } from '@nativescript-community/typeorm/browser/error/DriverPackageNotInstalledError'; | ||
import { DataSource, DriverOptionNotSetError, DriverPackageNotInstalledError } from 'typeorm/browser'; | ||
import { AbstractSqliteDriver } from 'typeorm/browser/driver/sqlite-abstract/AbstractSqliteDriver'; | ||
import * as NSQlite from '../sqlite'; | ||
@@ -6,0 +4,0 @@ import { NativescriptQueryRunner } from './NativescriptQueryRunner'; |
@@ -1,3 +0,3 @@ | ||
import { ObjectLiteral } from '@nativescript-community/typeorm/browser/common/ObjectLiteral'; | ||
import { AbstractSqliteQueryRunner } from '@nativescript-community/typeorm/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner'; | ||
import { ObjectLiteral, QueryRunner } from 'typeorm/browser'; | ||
import { AbstractSqliteQueryRunner } from 'typeorm/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner'; | ||
import { NativescriptDriver } from './NativescriptDriver'; | ||
@@ -7,3 +7,3 @@ /** | ||
*/ | ||
export declare class NativescriptQueryRunner extends AbstractSqliteQueryRunner { | ||
export declare class NativescriptQueryRunner extends AbstractSqliteQueryRunner implements QueryRunner { | ||
/** | ||
@@ -17,3 +17,3 @@ * Database driver used by connection. | ||
*/ | ||
query(query: string, parameters?: any[]): Promise<any>; | ||
query(query: string, parameters?: any[], useStructuredResult?: boolean): Promise<any>; | ||
/** | ||
@@ -20,0 +20,0 @@ * Parametrizes given object of values. Used to create column=value queries. |
@@ -1,5 +0,4 @@ | ||
import { QueryRunnerAlreadyReleasedError } from '@nativescript-community/typeorm/browser/error/QueryRunnerAlreadyReleasedError'; | ||
import { QueryFailedError } from '@nativescript-community/typeorm/browser/error/QueryFailedError'; | ||
import { AbstractSqliteQueryRunner } from '@nativescript-community/typeorm/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner'; | ||
import { Broadcaster } from '@nativescript-community/typeorm/browser/subscriber/Broadcaster'; | ||
import { QueryFailedError, QueryResult, QueryRunnerAlreadyReleasedError } from 'typeorm/browser'; | ||
import { AbstractSqliteQueryRunner } from 'typeorm/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner'; | ||
import { Broadcaster } from 'typeorm/browser/subscriber/Broadcaster'; | ||
import { NativescriptDriver } from './NativescriptDriver'; | ||
@@ -23,3 +22,3 @@ import * as NSQlite from '../sqlite'; | ||
*/ | ||
async query(query, parameters) { | ||
async query(query, parameters, useStructuredResult) { | ||
if (this.isReleased) { | ||
@@ -44,3 +43,8 @@ throw new QueryRunnerAlreadyReleasedError(); | ||
} | ||
return result; | ||
if (useStructuredResult) { | ||
return { records: result, raw: result }; | ||
} | ||
else { | ||
return result; | ||
} | ||
} | ||
@@ -47,0 +51,0 @@ catch (err) { |
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
Sorry, the diff of this file is not supported yet
121103
0.56%1756
1.04%83
13.7%