diff options
Diffstat (limited to 'files/fr/web/api/idbindex/objectstore/index.md')
-rw-r--r-- | files/fr/web/api/idbindex/objectstore/index.md | 107 |
1 files changed, 48 insertions, 59 deletions
diff --git a/files/fr/web/api/idbindex/objectstore/index.md b/files/fr/web/api/idbindex/objectstore/index.md index 72f83bc88e..3ca57791da 100644 --- a/files/fr/web/api/idbindex/objectstore/index.md +++ b/files/fr/web/api/idbindex/objectstore/index.md @@ -3,33 +3,34 @@ title: IDBIndex.objectStore slug: Web/API/IDBIndex/objectStore translation_of: Web/API/IDBIndex/objectStore --- -<p>{{ APIRef("IndexedDB") }}</p> +{{ APIRef("IndexedDB") }} -<div> -<p>La propriètè <strong><code>objectStore</code></strong> de l'interface {{domxref("IDBIndex")}} renvoie un accès au magasin d'objet que référence l'index.</p> +La propriètè **`objectStore`** de l'interface {{domxref("IDBIndex")}} renvoie un accès au magasin d'objet que référence l'index. -<p>{{AvailableInWorkers}}</p> -</div> +{{AvailableInWorkers}} -<h2 id="Syntaxe">Syntaxe</h2> +## Syntaxe -<pre class="brush: js">var indexObjectStore = myIndex.objectStore;</pre> +```js +var indexObjectStore = myIndex.objectStore; +``` -<h2 id="Valeur">Valeur</h2> +## Valeur -<p>Un {{ domxref("IDBObjectStore","accès au magasin d'objet") }}.</p> +Un {{ domxref("IDBObjectStore","accès au magasin d'objet") }}. -<h2 id="Example">Example</h2> +## Example -<p>Dans l'exemple suivant on ouvre une transaction puis un magasin d'objet et enfin l'index <code>lName</code>.</p> +Dans l'exemple suivant on ouvre une transaction puis un magasin d'objet et enfin l'index `lName`. -<p>Le magasin d'objet référencé par l'index est afficher sur la console, quelque chose ressemblant à:</p> +Le magasin d'objet référencé par l'index est afficher sur la console, quelque chose ressemblant à: -<pre>IDBObjectStore { name: "contactsList", keyPath: "id", indexNames: DOMStringList[7], transaction: IDBTransaction, autoIncrement: false }</pre> + IDBObjectStore { name: "contactsList", keyPath: "id", indexNames: DOMStringList[7], transaction: IDBTransaction, autoIncrement: false } -<p>Finalement, On itère sur tous les enregistrements pour en insérer les données dans un tableau HTML. En utilisant la méthode {{domxref("IDBIndex.openCursor")}} qui travaille de la même façon que la méthode {{domxref("IDBObjectStore.openCursor")}} de l'{{domxref("IDBObjectStore","accès")}} au magasin d'objet sauf que les enregistrements sont renvoyés dans l'ordre de l'index et non celui du magasin d'objet.</p> +Finalement, On itère sur tous les enregistrements pour en insérer les données dans un tableau HTML. En utilisant la méthode {{domxref("IDBIndex.openCursor")}} qui travaille de la même façon que la méthode {{domxref("IDBObjectStore.openCursor")}} de l'{{domxref("IDBObjectStore","accès")}} au magasin d'objet sauf que les enregistrements sont renvoyés dans l'ordre de l'index et non celui du magasin d'objet. -<pre class="brush:js">function displayDataByIndex() { +```js +function displayDataByIndex() { tableEntry.innerHTML = ''; //ouvre un transaction @@ -47,14 +48,14 @@ translation_of: Web/API/IDBIndex/objectStore var cursor = event.target.result; if(cursor) { var tableRow = document.createElement('tr'); - tableRow.innerHTML = '<td>' + cursor.value.id + '</td>' - + '<td>' + cursor.value.lName + '</td>' - + '<td>' + cursor.value.fName + '</td>' - + '<td>' + cursor.value.jTitle + '</td>' - + '<td>' + cursor.value.company + '</td>' - + '<td>' + cursor.value.eMail + '</td>' - + '<td>' + cursor.value.phone + '</td>' - + '<td>' + cursor.value.age + '</td>'; + tableRow.innerHTML = '<td>' + cursor.value.id + '</td>' + + '<td>' + cursor.value.lName + '</td>' + + '<td>' + cursor.value.fName + '</td>' + + '<td>' + cursor.value.jTitle + '</td>' + + '<td>' + cursor.value.company + '</td>' + + '<td>' + cursor.value.eMail + '</td>' + + '<td>' + cursor.value.phone + '</td>' + + '<td>' + cursor.value.age + '</td>'; tableEntry.appendChild(tableRow); cursor.continue(); @@ -62,39 +63,27 @@ translation_of: Web/API/IDBIndex/objectStore console.log('Tous les enregistrements ont été affichés.'); } }; -};</pre> - -<div class="note"><p><strong>Note :</strong> Pour un exemple de travail complet, voir notre <a href="https://github.com/mdn/to-do-notifications/">To-do Notifications</a> app (<a href="http://mdn.github.io/to-do-notifications/">view example live</a>).</p></div> - -<h2 id="Spécification">Spécification</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">Spécification</th> - <th scope="col">Statut</th> - <th scope="col">Commentaire</th> - </tr> - <tr> - <td>{{SpecName('IndexedDB', '#widl-IDBIndex-objectStore', 'objectStore')}}</td> - <td>{{Spec2('IndexedDB')}}</td> - <td> </td> - </tr> - </tbody> -</table> - -<h2 id="Browser_compatibility">Compatibilité des navigateurs</h2> - -<p>{{Compat("api.IDBIndex.objectStore")}}</p> - -<h2 id="Voir_aussi">Voir aussi</h2> - -<ul> - <li>{{domxref("IndexedDB_API.Using_IndexedDB","Utiliser IndexedDB")}}</li> - <li>{{domxref("IDBDatabase","Débuter une connexion")}}</li> - <li>{{domxref("IDBTransaction","Utilisé les transactions")}}</li> - <li>{{domxref("IDBKeyRange","Définir l'intervalle des clés")}}</li> - <li>{{domxref("IDBObjectStore","Accès aux magasins d'objets")}}</li> - <li>{{domxref("IDBCursor","Utiliser les curseur")}}</li> - <li>Exemple de référence: <a href="https://github.com/mdn/to-do-notifications/tree/gh-pages">To-do Notifications</a> (<a href="http://mdn.github.io/to-do-notifications/">view example live</a>.)</li> -</ul> +}; +``` + +> **Note :** Pour un exemple de travail complet, voir notre [To-do Notifications](https://github.com/mdn/to-do-notifications/) app ([view example live](http://mdn.github.io/to-do-notifications/)). + +## Spécification + +| Spécification | Statut | Commentaire | +| -------------------------------------------------------------------------------------------- | ---------------------------- | ----------- | +| {{SpecName('IndexedDB', '#widl-IDBIndex-objectStore', 'objectStore')}} | {{Spec2('IndexedDB')}} | | + +## Compatibilité des navigateurs + +{{Compat("api.IDBIndex.objectStore")}} + +## Voir aussi + +- {{domxref("IndexedDB_API.Using_IndexedDB","Utiliser IndexedDB")}} +- {{domxref("IDBDatabase","Débuter une connexion")}} +- {{domxref("IDBTransaction","Utilisé les transactions")}} +- {{domxref("IDBKeyRange","Définir l'intervalle des clés")}} +- {{domxref("IDBObjectStore","Accès aux magasins d'objets")}} +- {{domxref("IDBCursor","Utiliser les curseur")}} +- Exemple de référence: [To-do Notifications](https://github.com/mdn/to-do-notifications/tree/gh-pages) ([view example live](http://mdn.github.io/to-do-notifications/).) |