aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/api/idbfactory/cmp
diff options
context:
space:
mode:
Diffstat (limited to 'files/fr/web/api/idbfactory/cmp')
-rw-r--r--files/fr/web/api/idbfactory/cmp/index.html189
1 files changed, 189 insertions, 0 deletions
diff --git a/files/fr/web/api/idbfactory/cmp/index.html b/files/fr/web/api/idbfactory/cmp/index.html
new file mode 100644
index 0000000000..10fd12cbad
--- /dev/null
+++ b/files/fr/web/api/idbfactory/cmp/index.html
@@ -0,0 +1,189 @@
+---
+title: IDBFactory.cmp()
+slug: Web/API/IDBFactory/cmp
+tags:
+ - API
+ - IDBFactory
+ - IndexedDB
+ - Méthode
+ - Reference
+translation_of: Web/API/IDBFactory/cmp
+---
+<div>{{APIRef("IndexedDB")}}</div>
+
+<p>La méthode <strong><code>cmp()</code></strong> de l'interface {{domxref("IDBFactory")}} compare deux valeurs de clé et détermine si celles-ci sont égales et sinon, laquelle est la plus grande. Cette opération est utilisée pour l'enregistrement et le parcours des données.</p>
+
+<p>{{AvailableInWorkers}}</p>
+
+<p class="note"><strong>Note :</strong> Cette méthode ne doit pas être utilisée pour comparer des valeurs JavaScript. En effet, de nombreuses valeurs JavaScript ne sont pas des valeurs valides pour représenter des clés IndexedDB (les booléens et les objets par exemple), dans ces cas, elles peuvent être traitées comme des clés égales (ainsi IndexedDB ignore les tableaux ayant des propriétés non numériques et les considère comme des tableaux vides, de sorte que les éventuels tableaux non numériques seront considérés comme égaux). Une exception est levée si l'une des valeurs n'est pas une clé valide.</p>
+
+<h2 id="Syntaxe">Syntaxe</h2>
+
+<pre class="syntaxbox">var resultat = window.indexedDB.cmp(a, b);</pre>
+
+<h3 id="Paramètres">Paramètres</h3>
+
+<dl>
+ <dt><code>a</code></dt>
+ <dd>La première clé pour la comparaison.</dd>
+ <dt><code>b</code></dt>
+ <dd>La deuxième clé pour la comparaison.</dd>
+</dl>
+
+<h3 id="Valeur_de_retour">Valeur de retour</h3>
+
+<p>Un entier qui indique le résultat de la comparaison. Le tableau ci-dessous indique les valeurs possibles et leur signification :</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Valeur renvoyée</th>
+ <th scope="col">Description</th>
+ </tr>
+ <tr>
+ <td>-1</td>
+ <td>La clé 1 est plus petite que la clé 2.</td>
+ </tr>
+ <tr>
+ <td>0</td>
+ <td>Les deux clé sont égales.</td>
+ </tr>
+ <tr>
+ <td>1</td>
+ <td>La clé 1 est plus grande que la clé 2.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Exceptions_levées">Exceptions levées</h3>
+
+<p>Cette méthode peut lever une exception {{domxref("DOMException")}} de type :</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Exception</th>
+ <th scope="col">Description</th>
+ </tr>
+ <tr>
+ <td><a href="/fr/docs/Web/API/DOMError"><code>DataError</code></a></td>
+ <td>L'une des clés fournies n'est pas valide.</td>
+ </tr>
+ </thead>
+</table>
+
+<h2 id="Exemples">Exemples</h2>
+
+<pre class="brush: js;">var a = 1;
+var b = 2;
+var result = window.indexedDB.cmp(a, b);
+console.log( "Résultat de la comparaison : " + 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-IDBFactory-cmp-short-any-first-any-second', 'cmp')}}</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>workers</em></td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatGeckoMobile("37.0")}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>10</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>workers</em></td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatGeckoMobile("37.0")}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>10</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>