Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
angular-sql-storage
Advanced tools
Manage SQlLite connection and create tables.
##Get Started
bower install angular-sql-storage --save
Include angular-sql-storage.js
(or angular-sql-storage.min.js
) from the dist directory in your index.html
, after including Angular itself.
Add 'sf.sqlStorage'
to your main module's list of dependencies.
When you're done, your setup should look similar to the following:
<!doctype html>
<html ng-app="myApp">
<head>
</head>
<body>
...
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"></script>
<script src="bower_components/angular-sql-storage/angular-sql-storage.min.js"></script>
...
<script>
var myApp = angular.module('myApp', ['sf.sqlStorage']);
</script>
...
</body>
</html>
##Configuration
###setDatabaseConfig
You can define your name and database version number
The version number let you manage migrations automatically.
The service compares the current version with the latest and runs all updates accordingly
Default: name: database.db
version: 1
myApp.config(function (sqlStorageServiceProvider) {
sqlStorageServiceProvider
.setDatabaseConfig({
name: 'myapp.db',
version: 0.1
});
});
###setDatabaseSchema
You need to define the table definition to create tables
Params:
defaultFields
[Array] - Define fields which appear in all tables
name
[String] - Sql field nametype
[String] - Sql field typeprimayKey
[Boolean] - Add PRIMARY KEY constraint to field.unique
[Boolean] - Add UNIQUE constraint to field.tables
[Object] - Define tables with specific structure
table_name
[String] - Name of tableindexed_fields
[Array] - Add indexed fields to table (structure like defaultFields)myApp.config(function (sqlStorageServiceProvider) {
sqlStorageServiceProvider
.setDatabaseSchema({
defaultFields: [{
name: 'id',
type: 'NVARCHAR(32)',
primayKey: true,
unique: true,
}, {
name: 'payload',
type: 'TEXT',
},
tables: {
users: {
table_name: 'users',
indexed_fields: [{
name: 'age',
type: 'INTEGER',
}],
},
}]
});
});
###setDatabaseInstance
Set the database instance instead of window.openDatabase.
Example, you can use cordova and ngCordova to instantiate your database (Function is invoke by angular $injector.invoke service).
myApp.config(function (sqlStorageServiceProvider) {
sqlStorageServiceProvider
.setDatabaseInstance(databaseInstance);
function databaseInstance($cordovaSQLite) {
return $cordovaSQLite.openDB('myapp.db', 1);
}
});
###addUpdater
You could define migration scripts when you update your database schema. Just need to define verison and script.
You can access to this following instance variable :
this._database
: Database Instance.Params:
version
[Float] - Version which need to run the script.method
[Function] - Method to run by $injector.inoke().myApp.config(function (sqlStorageServiceProvider) {
sqlStorageServiceProvider
.addUpdater({
version: 1.1,
method: updateMethod,
});
function updateMethod($cordovaSQLite) {
var _database = this._database;
var query = 'ALTER TABLE users ADD COLUMN name TEXT';
return $cordovaSQLite.execute(_database, query);
});
});
##API Documentation
##initDatabase
Init instance if you want to update earlier. This method is called by getDatabase too.
Returns: Database Instance
###getDatabase
Just get database instance.
Returns: Database Instance
###initTables
Create Sql tables and run migration if needed
Returns: Database Instance
###deleteDatas Drop all tables (of the database).
###execute
Helpers to execute sql queries.
Returns: Query result
FAQs
Manage SQlLite connection and create tables
The npm package angular-sql-storage receives a total of 3 weekly downloads. As such, angular-sql-storage popularity was classified as not popular.
We found that angular-sql-storage demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.