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-query
Advanced tools
bower install angular-sql-query --save
Include angular-sql-query.js
(or angular-sql-query.min.js
) from the dist directory in your index.html
, after including Angular itself.
Add 'sf.sqlQuery'
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-query/angular-sql-query.min.js"></script>
...
<script>
var myApp = angular.module('myApp', ['sf.sqlQuery']);
</script>
...
</body>
</html>
For using this module, your database need to be architectured with these fields:
id
: Unique key for data.payload
: Object data stringify with angular.toJson.For some extra helpers regarding storage, you can look at this module angular-sql-storage.
Example
var user = new SqlQueryService(name, databaseFn, options);
Params
name
[String] - Table namedatabase
[Function] - Function that return SQL database instance.options
[Function] - Query options
indexed_fields
[Array] - Reference field by adding a column in the table.function databaseInstance() {
return $q.when($window.openDatabase('test', '1', 'database', 200000));
}
var user = new SqlQueryService('user', databaseInstance, {
indexed_fields: ['name'],
});
Get data by its id
Params
id
: Data idReturns: payload
user.getBackUp(1);
All datas
Returns: [Array] payload
user.listBackUp();
All datas corresponding to query.
If field is referenced in options, query can be set directly in SQl Query. Also, a javascript filter is used.
You need to pass an object; the key is the field name and the value is the query value.
IN
query.LIKE
query.Params:
params
: [Object] Filter datasReturns: [Array] payload
user.queryBackUp({
name: ['Jean', 'Paul'],
connected: true
});
Save new object data
Params:
id
: Data keydatas
: Data objectReturns: [Object] Data saved
user.saveBackUp(1, { name: 'Jean', connected: false });
Update database object
Params:
data
: Object datas (with id).Returns: [Object] Data updated
user.updateBackUp({ id: 1, name: 'Paul', connected: false });
Remove database object
Params:
id
: Object key.Returns: SQL remove result
user.removeBackUp(1);
Modify multiple datas
It's possible to update or remove datas with one method called.
You can delete a data by setting an the object key _delete
to true.
Params:
datas
: Array of objects to update.Returns: SQL update result
user.bulkDocsBackUp([{
id: 1, name: 'Jean', connected: true,
id: 2, name: 'Paul', connected: false, _deleted: true
}]);
Directly make an SQL query.
Params:
query
: SQL query.datas
: SQL params.Returns: SQL result
user.execute('SELECT * FROM user WHERE id=?', [1]);
FAQs
Make simple query on a SQLite database
The npm package angular-sql-query receives a total of 5 weekly downloads. As such, angular-sql-query popularity was classified as not popular.
We found that angular-sql-query 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.