diff options
Diffstat (limited to 'files/fr/web/api/idbobjectstore/indexnames/index.html')
| -rw-r--r-- | files/fr/web/api/idbobjectstore/indexnames/index.html | 188 |
1 files changed, 188 insertions, 0 deletions
diff --git a/files/fr/web/api/idbobjectstore/indexnames/index.html b/files/fr/web/api/idbobjectstore/indexnames/index.html new file mode 100644 index 0000000000..c3cd0288e6 --- /dev/null +++ b/files/fr/web/api/idbobjectstore/indexnames/index.html @@ -0,0 +1,188 @@ +--- +title: IDBObjectStore.indexNames +slug: Web/API/IDBObjectStore/indexNames +tags: + - API + - IDBObjectStore + - IndexedDB + - Propriété + - Reference +translation_of: Web/API/IDBObjectStore/indexNames +--- +<div>{{APIRef("IndexedDB")}}</div> + +<p>La propriété <strong><code>indexNames</code></strong>, rattachée à l'interface {{domxref("IDBObjectStore")}}, renvoie la liste des noms des index pour les objets du magasin d'objets courant.</p> + +<p>{{AvailableInWorkers}}</p> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox">var myindexNames = objectStore.indexNames;</pre> + +<h3 id="Valeur">Valeur</h3> + +<p>Une liste {{domxref("DOMStringList")}}.</p> + +<h2 id="Exemples">Exemples</h2> + +<p>Dans l'exemple suivant, on initialise une transaction de lecture/écriture sur une base de données en ajoutant des données dans un magasin d'objets via la méthode <code>add()</code>. Une fois l'objet créé, on affiche <code>objectStore.indexNames</code> en sortie de la console. Pour un exemple complet et fonctionnel, vous pouvez utiliser notre application <a href="https://github.com/mdn/to-do-notifications/">To-do Notifications</a> (<a href="https://mdn.github.io/to-do-notifications/">tester la démo</a>).</p> + +<pre class="brush: js">// On commence par ouvrir la base de données +var DBOpenRequest = window.indexedDB.open("toDoList", 4); + +DBOpenRequest.onsuccess = function(event) { + note.innerHTML += '<li>Base de données initialisée.</li>'; + + // On enregistre le résultat de l'ouverture + // dans la variable db afin de l'utiliser + // ensuite + db = this.result; + + // On exécute la fonction addData() afin + // d'ajouter des données à la base de données + addData(); +}; + +function addData() { + // On crée un nouvel objet prêt à être inséré + // dans la base de données + var newItem = [ { taskTitle: "Walk dog", hours: 19, minutes: 30, day: 24, month: "December", year: 2013, notified: "no" } ]; + + // On ouvre une transaction en lecture/écriture + // vers la base de données afin d'ajouter des + // données + var transaction = db.transaction(["toDoList"], "readwrite"); + + // On indique le succès de la transaction + transaction.oncomplete = function(event) { + note.innerHTML += '<li>Transaction terminée : modification finie.</li>'; + }; + + + transaction.onerror = function(event) { + note.innerHTML += '<li>Transaction non-ouverte à cause d'une erreur. Les doublons ne sont pas autorisés.</li>'; + }; + + // On crée un magasin d'objet pour la transaction + // et on affiche indexNames dans la console + var objectStore = transaction.objectStore("toDoList"); + console.log(objectStore.indexNames); + + // On ajoute l'objet newItem au magasin d'objets + var objectStoreRequest = objectStore.add(newItem[0]); + + objectStoreRequest.onsuccess = function(event) { + // On indique le succès de l'ajout de l'objet + // dans la base de données + note.innerHTML += '<li>Un nouvel élément a été ajouté dans la base de données.</li>'; + }; +};</pre> + +<h2 id="Spécifications">Spécifications</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Spécification</th> + <th scope="col">État</th> + <th scope="col">Commentaires</th> + </tr> + <tr> + <td>{{SpecName('IndexedDB', '#widl-IDBObjectStore-indexNames', 'indexNames')}}</td> + <td>{{Spec2('IndexedDB')}}</td> + <td> </td> + </tr> + </tbody> +</table> + +<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2> + +<div>{{CompatibilityTable}}</div> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Fonctionnalité</th> + <th>Chrome</th> + <th>Edge</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari (WebKit)</th> + </tr> + <tr> + <td>Support simple</td> + <td>23{{property_prefix("webkit")}}<br> + 24</td> + <td>{{CompatVersionUnknown}}</td> + <td>10 {{property_prefix("moz")}}<br> + {{CompatGeckoDesktop("16.0")}}</td> + <td>10</td> + <td>15</td> + <td>7.1</td> + </tr> + <tr> + <td>Disponible dans les <em>web workers</em></td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatGeckoMobile("37.0")}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Fonctionnalité</th> + <th>Android</th> + <th>Webview Android</th> + <th>Edge</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Phone</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + <th>Chrome pour Android</th> + </tr> + <tr> + <td>Support simple</td> + <td>4.4</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatGeckoMobile("22.0")}}</td> + <td>10</td> + <td>22</td> + <td>8</td> + <td>{{CompatVersionUnknown}}</td> + </tr> + <tr> + <td>Disponible dans les <em>web workers</em></td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatGeckoMobile("37.0")}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="Voir_aussi">Voir aussi</h2> + +<ul> + <li><a href="/fr/docs/Web/API/API_IndexedDB/Using_IndexedDB">Utiliser IndexedDB</a></li> + <li>Initier une connexion : {{domxref("IDBDatabase")}}</li> + <li>Utiliser les transactions : {{domxref("IDBTransaction")}}</li> + <li>Définir un intervalle de clés : {{domxref("IDBKeyRange")}}</li> + <li>Récupérer et modifier les données : {{domxref("IDBObjectStore")}}</li> + <li>Utiliser les curseurs {{domxref("IDBCursor")}}</li> + <li>Exemple de référence : <a class="external" href="https://github.com/mdn/to-do-notifications/tree/gh-pages">To-do Notifications</a> (<a class="external" href="https://mdn.github.io/to-do-notifications/">exemple <em>live</em></a>).</li> +</ul> |
