/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated, do not edit! package js.html.idb; /**

The IDBDatabase interface of the IndexedDB API provides asynchronous access to a connection to a database. Use it to create, manipulate, and delete objects in that database. The interface also provides the only way to get a transaction and manage versions on that database.

Inherits from: EventTarget



Documentation for this class was provided by MDN. */ @:native("IDBDatabase") extern class Database extends js.html.EventTarget { /** Name of the connected database. */ var name(default,null) : String; /** A list of the names of the object stores currently in the connected database. */ var objectStoreNames(default,null) : js.html.DOMStringList; var onabort : js.html.EventListener; var onerror : js.html.EventListener; var onversionchange : js.html.EventListener; /** The version of the connected database. When a database is first created, this attribute is the empty string. */ var version(default,null) : Any; function close() : Void; function createObjectStore( name : String, ?options : Dynamic ) : ObjectStore; function deleteObjectStore( name : String ) : Void; function setVersion( version : String ) : VersionChangeRequest; /**

Immediately returns an IDBTransaction object, and starts a transaction in a separate thread.  The method returns a transaction object (IDBTransaction) containing the objectStore() method, which you can use to access your object store. 

Parameters
storeNames
The names of object stores and indexes that are in the scope of the new transaction. Specify only the object stores that you need to access.
mode
Optional. The types of access that can be performed in the transaction. Transactions are opened in one of three modes: READ_ONLY, READ_WRITE, and VERSION_CHANGE. If you don't provide the parameter, the default access mode is READ_ONLY. To avoid slowing things down, don't open a READ_WRITE transaction, unless you actually need to write into the database.
Sample code

To start a transaction with the following scope, you can use the code snippets in the table. As noted earlier:

Scope Code
Single object store

var transaction = db.transaction(['my-store-name'], IDBTransaction.READ_ONLY);

Alternatively:

var transaction = db.transaction('my-store-name', IDBTransaction.READ_ONLY);

Multiple object stores var transaction = db.transaction(['my-store-name', 'my-store-name2'], IDBTransaction.READ_ONLY);
All object stores

var transaction = db.transaction(db.objectStoreNames, IDBTransaction.READ_ONLY);

You cannot pass an empty array into the storeNames parameter, such as in the following: var transaction = db.transaction([], IDBTransaction.READ_ONLY);.

Warning:  Accessing all obejct stores under the READ_WRITE mode means that you can run only that transaction. You cannot have writing transactions with overlapping scopes.
Returns
IDBTransaction
The transaction object.
Exceptions

This method can raise an IDBDatabaseException with the following codes:

Exception Description
NOT_ALLOWED_ERR The error is thrown for one of two reasons:
  • The close() method has been called on this IDBDatabase instance.
  • The object store has been deleted or removed.
NOT_FOUND_ERR One of the object stores doesn't exist in the connected database.
Throws DatabaseException. */ @:overload( function( storeNames : js.html.DOMStringList, mode : String ) :Transaction {} ) @:overload( function( storeNames : Array, mode : String ) :Transaction {} ) function transaction( storeName : String, mode : String ) : Transaction; }