paulocaldeira17 / angular-websql Goto Github PK
View Code? Open in Web Editor NEWAngular WebSql Service - Query less
License: MIT License
Angular WebSql Service - Query less
License: MIT License
Is it possible to add a package.json file for us who are sticking with NPM?
Hola! @txukytruky has created a ZenHub account for the paulocaldeira17 organization. ZenHub is the only project management tool integrated natively in GitHub – created specifically for fast-moving, software-driven teams.
To get set up with ZenHub, all you have to do is download the browser extension and log in with your GitHub account. Once you do, you’ll get access to ZenHub’s complete feature-set immediately.
ZenHub adds a series of enhancements directly inside the GitHub UI:
Still curious? See more ZenHub features or read user reviews. This issue was written by your friendly ZenHub bot, posted by request from @txukytruky.
Hello!
how can i call 'not equal' !=
or 'Different' <>
operators with angular-websql ?
i want to put a dynamic parameter into my query condition like that:
db.del("Table", {"id_element":{'value':id ,'union':'AND'},'id_person' != id_parameter })
it's possible to do something like that using angular-websql?
thank's
create table with reference to an other table
an orm mapping like
createTable('article', {
/* ... */
"comments" : {
"type" : "HAS_MANY",
"table": "comment"
"field" : "ID_ARTICLE"
}
});
then you could optionally load comments objects as an array in the user object
$scope.db.select("article", {"id" : 5}, {"comments" : true}).then(function(){
console.log(results.rows.item(0).comments[0].name)
})
createTable('comment', {
/* ... */
"article" : {
"type" : "BELONG_TO",
"table": "article"
"field" : "ID_ARTICLE"
}
});
$scope.db.select("comment", {"id" : 9}, {"article" : true})
I have to change all the funcions in my programs or simply to change the select function in angular-websql to check for null values in the select function to return selectAll instead.
Hola! @paulocaldeira17 has created a ZenHub account for the paulocaldeira17 organization. ZenHub is the only project management tool integrated natively in GitHub – created specifically for fast-moving, software-driven teams.
To get set up with ZenHub, all you have to do is download the browser extension and log in with your GitHub account. Once you do, you’ll get access to ZenHub’s complete feature-set immediately.
ZenHub adds a series of enhancements directly inside the GitHub UI:
Still curious? See more ZenHub features or read user reviews. This issue was written by your friendly ZenHub bot, posted by request from @paulocaldeira17.
Hi.
Here's my suggestion to implement order by.
I've made a simple and fast implementation, didn't send pull request cause I'm no sure if it's well formatted, or if it's better just implement another param in select, anyway, just keep the suggestion
selectOrder: function (b, c, o, od) {
if(!od)
od = "ASC";
var d = "SELECT * FROM `{tableName}` WHERE {where} ORDER BY {order} {direction};";
var a = this.whereClause(c);
return this.executeQuery(this.replace(d, {
"{tableName}": b,
"{where}": a.w,
"{order}": o,
"{direction}": od
}), a.p);
},
Usage:
selectOrder(string tableName, object where, string field, string direction)
$scope.db.selectOrder("user", {
"condition": 1
}, "id",
"ASC")
.then(function (results) {
for (i = 0; i < results.rows.length; i++) {
console.log(results.rows.item(i));
}
});
Hey man, first i want congratz you for share this!
I wanna ask if you could add Insert or replace in the source?
insertOrReplace: function(c, e) {
var f = "INSERT OR REPLACE INTO {tableName}
({fields}) VALUES({values});";
var a = "",
b = "",
v = [];
for (var d in e) {
a += (Object.keys(e)[Object.keys(e).length - 1] == d) ? "" + d + "
" : "" + d + "
, ";
b += (Object.keys(e)[Object.keys(e).length - 1] == d) ? "?" : "?, ";
v.push(e[d]);
}
return this.executeQuery(this.replace(f, {
"{tableName}": c,
"{fields}": a,
"{values}": b
}), v);
}
Hello,
I just discovered your api, and it looks great !
I was just wondering if it could be possible for you to add a method "createOrUpdateTable", which will create a table, if the table does not exist or if the fields are similar, but in case some fields are added, just dingo instead an 'ALTER TABLE ADD COLUMN'.
Do you think it could be possible to have something like this ?
Thanks a lot.
Cheers.
I came across this small issue today, when I tried to create a table containing columns without specifying the "null" property. Leaving out this property made the whole query fail silently.
e.g. for me this does not work at all:
$rootScope.db.createTable('events', {
"uid": {
"type": "INTEGER",
"null": "NOT NULL",
"primary": true
},
"title": {
"type": "TEXT",
"null": "NOT NULL"
},
// …
"website": {
"type": "TEXT"
}
});
If I add "null": "NULL"
to the website
column definition, it works.
This behaviour is unexpected as allowing NULL should be the default (if not specified) besides it is not documented.
Anyway thanks for this useful module!
Hi
Thanks for the great library.
I needed to know if a table pre-exist in the database, couldn't see how to do it using your library so I added it in before createTable function:
tableExist: function(query){
var deferred = $q.defer();
db.transaction(function(tx) {
tx.executeSql("SELECT count(*) AS textist FROM sqlite_master WHERE type='table' AND name='"+query+"'", [], function(tx, results) {
var ex = results.rows.item(0).textist;
deferred.resolve(ex);
}, function(tx, e){
console.log("There has been an error: " + e.message);
deferred.reject();
});
});
return deferred.promise;
}
Use in code.
$scope.db.tableExist("tablename").then(function(result) {
if(result == 0){
console.log('No table found');
} else {
console.log('Table found');
}
});
Hope this helps someone :)
Could you provide an example of different types of oporators?
I've tried
db.select('categories', { "supcat_id": { "value": '<5' } }).then(function(results) { console.log(results.rows); })
but the query is always SELECT * FROM categories WHERE supcat_id = ?;
with no results.
Hi,
i would like to know if i can do complex select? like:
select name, sum(orders) from orders group by name;
thank for your help
I'm using angular 1.4.8 and using select all rising infinite loop digest on angular ng-repeat
$scope.loadData = function () { $scope.db.selectAll("model").then(function (results) { $scope.data = results.rows; }); };
Hello,
I have problem when i try to update field with more dynamic parameter as condition
db.update("Table", {"notok": '1'}, {"id_person": {'value':id_person_dynamic_parameter ,'union':'AND'},'id_element': id_second_dynamic_parameter});
i get this error
UPDATE `Table` SET `notok`= ? WHERE `id_person` undefined ? AND `id_element`=?; ["1", "4377C91AF07E430E949C6E277B072787", 1] angular-websql.min.js:6
There has been an error: could not prepare statement (1 near "undefined": syntax error)
Each field works when i update just one condition .
it's a bug or just it's impossible to update like that ?
Hello,
i have problem when i want update more fields.
$scope.db.update("contacts",
{ "firstName": $scope.firstName,
"lastName": $scope.lastName
},
{
"id": $routeParams.id
}
).then(function(){
$location.path("/contact/"+$routeParams.id);
})
i have this error :
2014-07-31 11:43:48.293 23rc[49886:60b] UPDATE 'contacts' SET 'firstName'= ?'lastName'= ? WHERE 'id'=?; johne,doe,1
2014-07-31 11:43:48.296 23rc[49886:60b] There has been an error: could not prepare statement (1 near "'lastName'": syntax error)
Each field works when i update just one.
it's a bug or just it's impossible to update more fields ?
Hi
I wanted to try out the angular-websql but got an error with bower install:
ECONFLICT Unable to find suitable version for angular
I use Angular 1.3.13. Seems that the angular-websql runs only with Angular 1.2.x.
Is there an update planned to support newer versions of angular?
Thanks
Hello,
I actually use angular-websql perfectly with Goole Chrome browser.But that's not working with firefox.
var db;
db = $webSql.openDatabase('_db', '1.0', 'mydb DB', 2 * 1024 * 1024);
db.dropTable('_Table');
...
i have TypeError: db is undefined
error when i call db
's functions.
So do you have any idea about this case?
Thank's
Values coming from variables should be passed as parameters to overcome escaping problems.
e.g. instead of using
db.execute('INSERT INTO `{tableName}` ({fields}) VALUES({values})');
the values for each field should be represented with a '?' character and passed as a parameter to the execute()-function (dummy code ahead):
db.execute('INSERT INTO `{tableName}` ({fields}) VALUES(?, ?)', {values}[0], {values}[1]);
See this question on Stack Overflow for more information.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.