indexeddb

IndexedDB:浏览器里内置的数据库

巧了我就是萌 提交于 2019-12-06 22:47:41
IndexedDB是HTML5规范里新出现的浏览器里内置的数据库。对于在浏览器里存储数据,你可以使用cookies或local storage,但它们都是比较简单的技术,而IndexedDB提供了类似数据库风格的数据存储和使用方式。存储在IndexedDB里的数据是永久保存,不像cookies那样只是临时的。IndexedDB里提供了查询数据的功能,在online和offline模式下都能使用。你可以用IndexedDB存储大型数据。 IndexedDB里数据以对象的形式存储,每个对象都有一个key值索引。IndexedDB里的操作都是事务性的。一种对象存储在一个objectStore里,objectStore就相当于关系数据库里的表。IndexedDB可以有很多objectStore,objectStore里可以有很多对象。每个对象可以用key值获取。 IndexedDB vs LocalStorage IndexedDB和LocalStorage都是用来在浏览器里存储数据,但它们使用不同的技术,有不同的用途,你需要根据自己的情况适当的选择使用哪种。LocalStorage是用key-value键值模式存储数据,但跟IndexedDB不一样的是,它的数据并不是按对象形式存储。它存储的数据都是字符串形式。如果你想让LocalStorage存储对象,你需要借助 JSON

Why is this IndexedDB put command failing? Error: DataError: DOM IDBDatabase Exception 0

假如想象 提交于 2019-12-06 19:27:30
问题 I have successfully added the following to the objectStore when I created it: { name: "John Doe", age: 21 } I used the options: { keyPath: "id", autoIncrement: true } I am able to find that record and it shows the id = 1 . However, when I run this command below, it throws an error: var store = db.transaction( [ "employees" ], "readwrite" ).objectStore( "employees" ); var request = store.put( { name: "John Doe", age: 32 }, 1 ); This throws: DataError: DOM IDBDatabase Exception 0 Does anyone

from MySQL to IndexedDB

一个人想着一个人 提交于 2019-12-06 13:39:20
问题 Good day, I'm not sure if my question is even something possible or not, that's why I ask :) I'm developping an app which uses PHP/MySQL when it's online, but uses indexedDB when offline (well, this is the target!). For the user, it's only to read the database (nothing to write on). When online, I'd like to populate the indexedDB database in order to be able to use it as soon as the app is offline with the content of the MySQL database. What I want to do is something like that: function

IndexedDB callback not updating UI in angularjs

纵然是瞬间 提交于 2019-12-06 13:31:57
I am using the following library to access IndexedDB in Angularjs on a new Chrome App: https://github.com/aaronpowell/db.js When I try to update the UI on App startup by using this : db.orders.query().all().execute().done(function(results) { $scope.ordercount = results.length; }); in my main.html I have used the ordercount variable as: Orders : {{ordercount}} However, the UI is not updating unless I do ng-click or any other ng-* events. All I need is to show number of orders when my app is loaded. I tried $scope.apply(), but it throws error saying apply() is not available. Please help. Since

How to set initialState in @ngrx/core with a promise from indexedDB

青春壹個敷衍的年華 提交于 2019-12-06 08:25:58
I wanted to set the initial state in ngrx using the idb package which uses promise to fetch data, but am getting an error every time I tried to set it up. I read that @ngrx is synchronous does that mean it does not work with promises. The different methods I tried: this is my wrapper method for idb that loads in the data it works fine export function getInitialState(): Promise<any> { return StorageService.dB.loadInitialState('app-state'); } and the different methods I tried set the initial state method: 1 StoreModule.forRoot(reducers, {initialState: getInitialState}) method: 2 import { INITIAL

Property 'storage' does not exist on type 'Navigator'

冷暖自知 提交于 2019-12-06 08:11:45
I'm trying to get the quota storage information from an Angular2 component with this command line: navigator.storage.estimate().then((data) => console.log(data)); The command works properly in a pure Javascript script but it doesn't get compiled in Angular2/Typescript. Can you help me? Thanks I had the same problem and I couldn't find any available @types for the StorageManager interface. My temporary solutions was to manually declare it in my code. declare global { interface StorageEstimate { quota: number; usage: number; } interface Navigator { storage: { estimate: () => Promise

IndexedDB: 浏览器里内置的数据库简介

淺唱寂寞╮ 提交于 2019-12-06 07:57:19
一、概述: 所有的应用程序都需要“数据”支持。对于大多数的Web应用程序来说,数据是在服务器端进行组织和整理,然后由客户端(浏览器端)通过网络请求获取。 随着浏览器的处理能力不断增强,可以在浏览器端存储和操纵应用程序需要的数据,因此越来越多的网站开始考虑,将大量数据储存在本地客户端,这样可以减少用户等待从服务器端获取数据的时间。 现有的浏览器端数据储存方案,都不适合储存大量数据。Cookie不超过4KB,且每次请求都会发送回服务器端;Window.name属性缺乏安全性,且没有统一的标准;LocalStorage容量在2.5MB到10MB之间,且其以字符串形式进行存储。因此,需要一种新的技术解决方案,这就是IndexedDB诞生的背景。 IndexedDB 是一种浏览器端文档数据库,可以被网页脚本程序创建和操作。它允许储存大量数据,并且提供查询接口,且可以建立索引。 这些特性都是localStorage技术所不具备的。就数据库类型而言,IndexedDB不属于关系型数据库(不支持SQL查询语句),更接近NoSQL数据库。关系型数据库(如SQL Server,MySQL,Oracle等)的数据存储在表中;文档数据库(如MongoDB,CouchDB,Redis)将数据集作为个体对象来存储。 通过使用IndexedDB,开发者可以通过惯于在服务器端数据库几乎相同的方式进行创建、读取

IndexedDb transaction auto-commit behavior in edge cases

若如初见. 提交于 2019-12-06 06:51:49
Tx is committed when : request success callback returns - that means that multiple requests can be executed within transaction boundaries only when next request is executed from success callback of the previous one when your task returns to event loop It means that if no requests are submitted to it, it is not committed until it returns to event loop. These facts pose 2 problematic states : placing a new IDB request by enqueuing a new task to event loop queue from within the success callback of previous request instead of submitting new request synchronously in that case the first success

Metro IndexedDB, browsing the database

纵然是瞬间 提交于 2019-12-06 06:42:53
I am trying to store data in a "Metro" App for Windows 8 using IndexedDB. I would like to be able to browse the database (to monitor that my operations modify the data as intended). So my question is; Is there any way of viewing the actual database of a metro app (IE10)? (something like in Chrome Dev Tools (Resources > IndexedDB)) Regards Not that I know, but my linq2indexeddb library has a viewer in it. That way you can inspect the content of you database while debugging. The nuget package for Metro apps can be found here . And as last, I have a blogpost on how you can use it. The IE team has

Store a function in IndexedDb datastore

泄露秘密 提交于 2019-12-06 06:08:47
问题 Is it possible in any way to store a function in an IndexedDB datastore? I have done some searching and found nothing on the data types that IndexedDB supports. I tried simply adding a function and the instance of a function to an object store as follows, but it didn't work. var myclass = function () { self = this; self.name = 'Sam'; self.hello = function () { console.log('Hello ' + self.name); }; } var transaction = db.transaction(['codeobject'], 'readwrite'); var store = transaction