Code Monkey home page Code Monkey logo

websql-sqlite-service's Introduction

WebSqLite

WebSql ve Sqlite Uyumlu SqlService Kütüphanesi

İonic ile ( veya başka ui ) çalışırken device ile browser üzerinde testleri kolaylaştırmak için yapılmıştır.

Toplamda 5 adet methodu var bunlar:

En Son Değişiklikler (Last Update)

React native desteği değiştirildi

EventEmitter bağımlılığı kaldırıldı

Her sorguda database open oluyordu, bu sorun çözüldü

select

table : tablonun ismini içerir.

field : burada çekilecek sütun isimleri yer alıyor.

where : Sorgunun şartı.

values : Sorgu şartında bulunan '?' ifadelerinin dolduracak array.

order : Sorguda bulunacak order işlemine ait string ifade.

SqlService.select(table, field, where, values, order).then(function(res){ 
  // res : dönen sonuç
});

basit bir select sorgusu

$scope.list = [];
SqlService.select("chatList", "*", "chatId = ?", ["C0001"]).then(function(res){
	angular.forEach(res,function(item, index){
		$scope.list.push({
			message: item.message
		});
	})
});

like kullanımına bir örnek

$scope.list = [];
SqlService.select("chatList", "*", "(message LIKE ?)", ['%avare kodcu%']).then(function(res){
	angular.forEach(res,function(item, index){
		$scope.list.push({
			message: item.message
		});
	})
});

order by kullanımı

$scope.list = [];
SqlService.select("chatList", "*", "", "", "rowid, message").then(function(res){
	angular.forEach(res,function(item, index){
		$scope.list.push({
			message: item.message
		});
	})
});

Bunlara benzer kullanımları yapabilirsiniz.

insert

table : tablonun ismini içerir

row : burada insert yapılacak sütun isimleri yer alıyor

values : row içinde bulunan sütunlara ait değerler

SqlService.insert(table, row, values).then(function(res){
	//res : dönen sonuç
});

tekli insert işlemi

SqlService.insert("chatList", ["message"], ["avare kodcu"]).then(function(res){
	console.log(res)
});

çoklu insert işlemi

SqlService.insert("chatList", ["message"], [["avare kodcu"], ["Allah birdir!"]]).then(function(res){
	console.log(res)
});

update

table : tablonun ismini içerir

row : burada insert yapılacak sütun isimleri yer alıyor

values : row içinde bulunan sütunlara ait değerler

where: Sorgu şartı

wValues : Sorgu şartında bulunan '?' ifadelerinin dolduracak array

SqlService.update(table, row, values, where, wValues).then(function(res){
	//res : dönen sonuç
});

basit bir update işlemi

SqlService.update("chatList", ["message"], ["avare kodcu"], "chatId = ?", ["C0001"]).then(function(res){
	console.log(res);
});

sorguları değiştirerek çeşitli update işlemi yapılabilir.

delete

" Silmek ya da silmemek işte bütün mesele bu.." :) Bir veri asla silinmez ama ben yinede komutunu yazdım :)

table : tablonun ismini içerir

where: Sorgu şartı

values : Sorgu şartında bulunan '?' ifadelerinin dolduracak array

SqlService.delete(table, where, values).then(function(res){
	//res : dönen sonuç
});

basit bir delete işlemi

SqlService.delete("chatList", "chatId = ?", ["C0001"]).then(function(res){
	console.log(res);
});

ve son olarak

query

Bunu da karışık sorgular içeren, ufak bir işlem içeren, tablo oluşturmak için kullanılabilecek sorgular olur diye yazdım

sql : sorgunun tamamı

örneğiyle beraber ;

SqlService.query("CREATE TABLE IF NOT EXISTS chatList (chatId VARCHAR(255) NOT NULL, message TEXT)").then(function(res){
	console.log(res);
});

websql-sqlite-service's People

Contributors

abdurrahmanekr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.