@ -431,36 +432,40 @@ letters. Native <code>localCompare</code> will most of the time be the right cho
**Kind**: instance method of [<code>Datastore</code>](#Datastore)
**Kind**: instance method of [<code>Datastore</code>](#Datastore)
<aname="Datastore+ensureIndex"></a>
<aname="Datastore+ensureIndex"></a>
### neDB.ensureIndex(options, callback)
### neDB.ensureIndex(options, [callback])
<p>Ensure an index is kept for this field. Same parameters as lib/indexes
<p>Callback version of [ensureIndex](#Datastore+ensureIndex).</p>
This function acts synchronously on the indexes, however the persistence of the indexes is deferred with the
executor.
Previous versions said explicitly the callback was optional, it is now recommended setting one.</p>
**Kind**: instance method of [<code>Datastore</code>](#Datastore)
**Kind**: instance method of [<code>Datastore</code>](#Datastore)
**See**: Datastore#ensureIndex
**Params**
**Params**
- options <code>object</code>
- options <code>object</code>
- .fieldName <code>string</code> - <p>Name of the field to index. Use the dot notation to index a field in a nested document.</p>
- .fieldName <code>string</code>
- [.unique] <code>boolean</code><code> = false</code> - <p>Enforce field uniqueness. Note that a unique index will raise an error if you try to index two documents for which the field is not defined.</p>
- [.sparse] <code>boolean</code><code> = false</code> - <p>don't index documents for which the field is not defined. Use this option along with "unique" if you want to accept multiple documents for which it is not defined.</p>
- [.expireAfterSeconds] <code>number</code> - <p>if set, the created index is a TTL (time to live) index, that will automatically remove documents when the system date becomes larger than the date on the indexed field plus <code>expireAfterSeconds</code>. Documents where the indexed field is not specified or not a <code>Date</code> object are ignored</p>
<p>Async version of [ensureIndex](#Datastore+ensureIndex).</p>
<p>Ensure an index is kept for this field. Same parameters as lib/indexes
This function acts synchronously on the indexes, however the persistence of the indexes is deferred with the
executor.</p>
**Kind**: instance method of [<code>Datastore</code>](#Datastore)
**Kind**: instance method of [<code>Datastore</code>](#Datastore)
**See**: Datastore#ensureIndex
**Params**
**Params**
- options <code>object</code>
- options <code>object</code>
- .fieldName <code>string</code> - <p>Name of the field to index. Use the dot notation to index a field in a nested document.</p>
- .fieldName <code>string</code> - <p>Name of the field to index. Use the dot notation to index a field in a nested
- [.unique] <code>boolean</code><code> = false</code> - <p>Enforce field uniqueness. Note that a unique index will raise an error if you try to index two documents for which the field is not defined.</p>
document.</p>
- [.sparse] <code>boolean</code><code> = false</code> - <p>Don't index documents for which the field is not defined. Use this option along with "unique" if you want to accept multiple documents for which it is not defined.</p>
- [.unique] <code>boolean</code><code> = false</code> - <p>Enforce field uniqueness. Note that a unique index will raise an error
- [.expireAfterSeconds] <code>number</code> - <p>If set, the created index is a TTL (time to live) index, that will automatically remove documents when the system date becomes larger than the date on the indexed field plus <code>expireAfterSeconds</code>. Documents where the indexed field is not specified or not a <code>Date</code> object are ignored</p>
if you try to index two documents for which the field is not defined.</p>
- [.sparse] <code>boolean</code><code> = false</code> - <p>Don't index documents for which the field is not defined. Use this option
along with "unique" if you want to accept multiple documents for which it is not defined.</p>
- [.expireAfterSeconds] <code>number</code> - <p>If set, the created index is a TTL (time to live) index, that will
automatically remove documents when the system date becomes larger than the date on the indexed field plus
<code>expireAfterSeconds</code>. Documents where the indexed field is not specified or not a <code>Date</code> object are ignored.</p>
<aname="Datastore+removeIndex"></a>
<aname="Datastore+removeIndex"></a>
@ -487,31 +492,45 @@ field in a nested document.</p>
- fieldName <code>string</code> - <p>Field name of the index to remove. Use the dot notation to remove an index referring to a
- fieldName <code>string</code> - <p>Field name of the index to remove. Use the dot notation to remove an index referring to a
- [callback] [<code>countCallback</code>](#Datastore..countCallback) - <p>If given, the function will return undefined, otherwise it will return the Cursor.</p>
- [projection] [<code>projection</code>](#projection) | [<code>MultipleDocumentsCallback</code>](#MultipleDocumentsCallback) <code> = {}</code> - <p>MongoDB-style projection. If not given, will be
if(onePassDone){process.exit(1)}// Crash on purpose before rewrite done
if(onePassDone){process.exit(1)}// Crash on purpose before rewrite done
constl=Math.min(5000,length)// Force write by chunks of 5000 bytes to ensure data will be incomplete on crash
const{bytesWritten}=awaitfilehandle.write(buffer,offset,Math.min(5000,length))// Force write by chunks of 5000 bytes to ensure data will be incomplete on crash