npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

angular-sql-query

v2.4.0

Published

Make simple query on a SQLite database

Downloads

29

Readme

angular-sql-query

NPM version Build status Codacy Badge Codacy Coverage Dependency Status License Downloads

Get Started

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>

Configuration

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 name
  • database [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'],
});

API Documentation

.getBackUp()

Get data by its id

Params

  • id: Data id

Returns: payload

user.getBackUp(1);

.listBackUp()

All datas

Returns: [Array] payload

user.listBackUp();

.queryBackUp()

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.

  • You can pass an Array to make a IN query.
  • You can pass a Boolean for a 1 or 0 query.
  • You can pass an RegExp to make a LIKE query.

Params:

  • params: [Object] Filter datas

Returns: [Array] payload

user.queryBackUp({
  name: ['Jean', 'Paul'],
  connected: true
});

.saveBackUp()

Save new object data

Params:

  • id: Data key
  • datas: Data object

Returns: [Object] Data saved

user.saveBackUp(1, { name: 'Jean', connected: false });

.updateBackUp()

Update database object

Params:

  • data: Object datas (with id).

Returns: [Object] Data updated

user.updateBackUp({ id: 1, name: 'Paul', connected: false });

.removeBackUp()

Remove database object

Params:

  • id: Object key.

Returns: SQL remove result

user.removeBackUp(1);

.bulkDocsBackUp()

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
}]);

.execute()

Directly make an SQL query.

Params:

  • query: SQL query.
  • datas: SQL params.

Returns: SQL result

user.execute('SELECT * FROM user WHERE id=?', [1]);