aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/api/idbobjectstore/count
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/fr/web/api/idbobjectstore/count
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/fr/web/api/idbobjectstore/count')
-rw-r--r--files/fr/web/api/idbobjectstore/count/index.html183
1 files changed, 183 insertions, 0 deletions
diff --git a/files/fr/web/api/idbobjectstore/count/index.html b/files/fr/web/api/idbobjectstore/count/index.html
new file mode 100644
index 0000000000..3ac1c44d6e
--- /dev/null
+++ b/files/fr/web/api/idbobjectstore/count/index.html
@@ -0,0 +1,183 @@
+---
+title: IDBObjectStore.count()
+slug: Web/API/IDBObjectStore/count
+tags:
+ - API
+ - IDBObjectStore
+ - IndexedDB
+ - Méthode
+ - Reference
+translation_of: Web/API/IDBObjectStore/count
+---
+<div>{{APIRef("IndexedDB")}}</div>
+
+<p>La méthode <strong><code>count()</code></strong>, rattachée à l'interface {{domxref("IDBObjectStore")}}, renvoie un objet {{domxref("IDBRequest")}} et, dans un <em>thread</em> séparé, renvoie le nombre d'enregistrements qui correspondent à la clé ou à l'intervalle de clé ({{domxref("IDBKeyRange")}}) passé en argument. Si aucun argument n'est fourni, la méthode renvoie le nombre total d'enregistrements contenus dans le magasin d'objets.</p>
+
+<p>{{AvailableInWorkers}}</p>
+
+<h2 id="Syntaxe">Syntaxe</h2>
+
+<pre class="syntaxbox">var requete = ObjectStore.count(optionalKeyRange);</pre>
+
+<h3 id="Paramètres">Paramètres</h3>
+
+<dl>
+ <dt><code>optionalKeyRange</code></dt>
+ <dd>Une clé ou un intervalle de clé ({{domxref("IDBKeyRange")}}) qui indique le critère de comptage des enregistrements.</dd>
+</dl>
+
+<h3 id="Valeur_de_retour">Valeur de retour</h3>
+
+<p>Un objet {{domxref("IDBRequest")}} sur lequel seront déclenchés les différents évènements relatifs à l'opération.</p>
+
+<h3 id="Exceptions">Exceptions</h3>
+
+<p>Cette méthode peut déclencher une exception {{domxref("DOMException")}} ayant un des types suivants :</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Exception</th>
+ <th scope="col">Description</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>InvalidStateError</code></td>
+ <td>L'objet {{domxref("IDBObjectStore")}} a été supprimé.</td>
+ </tr>
+ <tr>
+ <td><code>TransactionInactiveError</code></td>
+ <td>La transaction associée à l'objet {{domxref("IDBObjectStore")}} est inactive.</td>
+ </tr>
+ <tr>
+ <td><code>DataError</code></td>
+ <td>La clé ou l'intervalle de clé passé en argument est invalide.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Exemples">Exemples</h2>
+
+<p>Dans ce fragment de code, on crée une transaction, on récupère un magasin d'objets puis on compte le nombre d'enregistrements contenus dans ce magasin grâce à la méthode <code>count()</code>. Lorsque l'évènement associé au succès de l'opération est déclenché, on inscrit le résultat dans la console.</p>
+
+<pre class="brush: js">var transaction = db.transaction(['fThings'], 'readonly');
+var objectStore = transaction.objectStore('fThings');
+
+var countRequest = objectStore.count();
+countRequest.onsuccess = function() {
+ console.log(countRequest.result);
+}
+</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-count-IDBRequest-any-key', 'count()')}}</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>Firefox OS</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>1.0.1</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>{{CompatNo}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatGeckoMobile("37.0")}}</td>
+ <td>{{CompatVersionUnknown}}</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>