From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/fr/web/api/idbobjectstore/getkey/index.html | 174 ++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 files/fr/web/api/idbobjectstore/getkey/index.html (limited to 'files/fr/web/api/idbobjectstore/getkey') diff --git a/files/fr/web/api/idbobjectstore/getkey/index.html b/files/fr/web/api/idbobjectstore/getkey/index.html new file mode 100644 index 0000000000..9e56d3b408 --- /dev/null +++ b/files/fr/web/api/idbobjectstore/getkey/index.html @@ -0,0 +1,174 @@ +--- +title: IDBObjectStore.getKey() +slug: Web/API/IDBObjectStore/getKey +translation_of: Web/API/IDBObjectStore/getKey +--- +

{{ APIRef("IndexedDB") }}

+ +
+

La méthode getKey() de l'interface {{domxref("IDBObjectStore")}} retourne un objet {{domxref("IDBRequest")}}, et, dans un thread séparé, retourne la clé sélectionnée par la requête spécifiée. Cela permet de retrouver un enregistrement spécifique depuis un espace de stockage déterminé.

+
+ +

Si la clé a bien été retrouvée, alors un clone structuré (une copie conforme) sera créée et servira comme résultat à l'objet de requête.

+ +

{{AvailableInWorkers}}

+ +

Syntax

+ +
var request = objectStore.getKey(key);
+ +

Parameters

+ +
+
key
+
La clé ou l'intervale de clé qui identifie l'enregistrement à retrouver.
+
+ +

Return Value

+ +

An {{domxref("IDBRequest")}} object on which subsequent events related to this operation are fired.

+ +

Exceptions

+ +

This method may raise a {{domxref("DOMException")}} of one of the following types:

+ + + + + + + + + + + + + + + + + + + + + + +
ExceptionDescription
TransactionInactiveErrorThis {{domxref("IDBObjectStore")}}'s transaction is inactive.
DataError +

The key or key range provided contains an invalid key.

+
InvalidStateErrorThe {{domxref("IDBObjectStore")}} has been deleted or removed.
+  
+ +

Example

+ +
let openRequest = indexedDB.open("telemetry");
+openRequest.onsuccess = (event) => {
+  let db = event.target.result;
+  let store = db.transaction("netlogs").objectStore("netlogs");
+
+  let today = new Date();
+  let yesterday = new Date(today);
+  yesterday.setDate(today.getDate() - 1);
+  let request = store.getKey(IDBKeyRange(yesterday, today));
+  request.onsuccess = (event) => {
+    let when = event.target.result;
+    alert("The 1st activity in last 24 hours was occurred at " + when);
+  };
+};
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('IndexedDB 2', '#dom-idbobjectstore-getkey', 'getKey()')}}{{Spec2('IndexedDB 2')}}Initial definition
+ +

Browser compatibility

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support{{CompatChrome(58)}}{{CompatGeckoDesktop("51.0")}}{{CompatUnknown}}{{CompatOpera(45)}}{{CompatUnknown}}
Available in workers{{CompatChrome(58)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatOpera(45)}}{{CompatUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroid WebviewChrome for AndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support{{CompatChrome(58)}}{{CompatChrome(58)}}{{CompatGeckoMobile("51.0")}}{{CompatUnknown}}{{CompatOperaMobile(45)}}{{CompatUnknown}}
Available in workers{{CompatChrome(58)}}{{CompatChrome(58)}}{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatOperaMobile(45)}}{{CompatUnknown}}
+
+ +

See also

+ + -- cgit v1.2.3-54-g00ecf