|
186 | 186 | service: { value: "", required: true }, |
187 | 187 | cloudant: { type: "cloudant", validate: validateServer}, |
188 | 188 | name: { value: "" }, |
189 | | - database: { value: "", required: true }, |
| 189 | + database: { value: "", required: true, validate: validateDatabase }, |
190 | 190 | payonly: { value: false }, |
191 | 191 | operation: { value: "insert" } |
192 | 192 | }, |
|
208 | 208 | service : { value: "", required: true }, |
209 | 209 | cloudant: { type: "cloudant", validate: validateServer }, |
210 | 210 | name : { value: "" }, |
211 | | - database: { value: "", required: true }, |
| 211 | + database: { value: "", required: true, validate: validateDatabase }, |
212 | 212 | search : { value: "_id_", required: true }, |
213 | 213 | design : { value: "" }, |
214 | 214 | index : { value: "" } |
|
286 | 286 | function validateServer(v) { |
287 | 287 | return this.service != "_ext_" || v != "_ADD_"; |
288 | 288 | } |
| 289 | + |
| 290 | + // https://wiki.apache.org/couchdb/HTTP_database_API#Naming_and_Addressing |
| 291 | + function validateDatabase(v) { |
| 292 | + return (v.indexOf('_') !== 0) && |
| 293 | + (v.search(/[A-Z\s\\/]/g) < 0) |
| 294 | + } |
289 | 295 | </script> |
290 | 296 |
|
291 | 297 | <script type="text/x-red" data-help-name="cloudant out"> |
|
307 | 313 | </p> |
308 | 314 | <p> |
309 | 315 | It is also possible to <b>delete</b> documents from the database by |
310 | | - providing values for <code>_id</b> and <code>_rev</code> and selecting |
| 316 | + providing values for <code>_id</code> and <code>_rev</code> and selecting |
311 | 317 | the <b>remove</b> option for the node. You can pass these values in the |
312 | 318 | <code>msg</code> object itself or as an object in the |
313 | 319 | <code>msg.payload</code>. |
314 | 320 | </p> |
| 321 | + <p> |
| 322 | + The <b>database name</b> must follow these rules: |
| 323 | + <ul> |
| 324 | + <li>No spaces</li> |
| 325 | + <li>All letters in small caps</li> |
| 326 | + <li>The first character can't be <code>_</code></li> |
| 327 | + </ul> |
| 328 | + </p> |
| 329 | + <p> |
| 330 | + Your document should avoid having top-level fields that start with |
| 331 | + <code>_</code>, with exceptions for <code>_id</code>, <code>_rev</code> |
| 332 | + and other <a href="https://wiki.apache.org/couchdb/HTTP_Document_API#Special_Fields"> |
| 333 | + CouchDB reserved words</a>. |
| 334 | + </p> |
315 | 335 | </script> |
316 | 336 |
|
317 | 337 | <script type="text/x-red" data-help-name="cloudant in"> |
|
338 | 358 | </p> |
339 | 359 | <p> |
340 | 360 | When querying using a <b>Search Index</b> you can pass the search |
341 | | - parameters as an object in <code>msg.payload</code>. For example, you |
342 | | - can pass an object like this: <code>{ query: "abc*", limit: 100 }</code> |
| 361 | + parameters as an object in <code>msg.payload</code>. |
| 362 | + </p> |
| 363 | + <p> |
| 364 | + For example, you can pass an object like this: |
| 365 | + <p> |
| 366 | + <code>{ query: "abc*", limit: 100 }</code> |
| 367 | + </p> |
| 368 | + <p> |
343 | 369 | to change the value of <code>limit</code>. You can find more information |
344 | | - on the accepted parameters in the <a |
| 370 | + about <b>Search Index</b> parameters in the <a |
345 | 371 | href="https://docs.cloudant.com/api.html?http#queries" target="_blank"> |
346 | 372 | official Cloudant documentation</a>. |
347 | 373 | </p> |
348 | 374 | <p> |
349 | 375 | The last method to retrieve documents is to simply get all of them by |
350 | 376 | selecting the option <b>all documents</b>. |
351 | 377 | </p> |
| 378 | + <p> |
| 379 | + The <b>database name</b> must follow these rules: |
| 380 | + <ul> |
| 381 | + <li>No spaces</li> |
| 382 | + <li>All letters in small caps</li> |
| 383 | + <li>The first character can't be <code>_</code></li> |
| 384 | + </ul> |
| 385 | + </p> |
352 | 386 | </script> |
0 commit comments