{"id":20130473,"url":"https://github.com/ravendb/ravendb-nodejs-client","last_synced_at":"2025-05-16T19:03:56.941Z","repository":{"id":17822507,"uuid":"82785093","full_name":"ravendb/ravendb-nodejs-client","owner":"ravendb","description":"RavenDB node.js client","archived":false,"fork":false,"pushed_at":"2025-04-24T06:44:09.000Z","size":7124,"stargazers_count":64,"open_issues_count":6,"forks_count":34,"subscribers_count":11,"default_branch":"v6.0","last_synced_at":"2025-04-24T07:44:05.013Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ravendb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-02-22T09:20:48.000Z","updated_at":"2025-04-10T08:01:30.000Z","dependencies_parsed_at":"2023-10-11T15:21:05.115Z","dependency_job_id":"74613b06-2881-4cc5-ad5e-9dfb65e58bad","html_url":"https://github.com/ravendb/ravendb-nodejs-client","commit_stats":{"total_commits":1204,"total_committers":27,"mean_commits":"44.592592592592595","dds":0.6785714285714286,"last_synced_commit":"a7718eb15d62780d40b4fe3968ae69635c03f116"},"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ravendb%2Fravendb-nodejs-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ravendb%2Fravendb-nodejs-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ravendb%2Fravendb-nodejs-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ravendb%2Fravendb-nodejs-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ravendb","download_url":"https://codeload.github.com/ravendb/ravendb-nodejs-client/tar.gz/refs/heads/v6.0","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254592368,"owners_count":22097011,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T20:38:47.689Z","updated_at":"2025-05-16T19:03:56.908Z","avatar_url":"https://github.com/ravendb.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node.js client for RavenDB NoSQL Database\n\n[![NPM](https://nodei.co/npm/ravendb.png?compact=true)](https://nodei.co/npm/ravendb/)\n\n[![build status](https://github.com/ravendb/ravendb-nodejs-client/workflows/tests/node/badge.svg?branch=v6.0)](https://github.com/ravendb/ravendb-nodejs-client/actions) [![Known Vulnerabilities](https://snyk.io/test/github/ravendb/ravendb-nodejs-client/badge.svg)](https://snyk.io/test/github/ravendb/ravendb-nodejs-client)\n\n\n## Installation\n\n```bash\nnpm install --save ravendb\n```\n\n## Releases\n\n* [Click here](https://github.com/ravendb/ravendb-nodejs-client/releases) to view all Releases and Changelog.\n\n## Documentation\n\n* This readme provides short examples for the following:  \n   [Getting started](#getting-started),  \n   [Asynchronous call types](#supported-asynchronous-call-types),  \n   [Crud example](#crud-example),  \n   [Query documents](#query-documents),  \n   [Attachments](#attachments),  \n   [Time series](#timeseries),  \n   [Bulk insert](#bulk-insert),  \n   [Changes API](#changes-api),  \n   [Streaming](#streaming),  \n   [Revisions](#revisions),  \n   [Suggestions](#suggestions),  \n   [Patching](#advanced-patching),  \n   [Subscriptions](#subscriptions),  \n   [Using object literals](#using-object-literals-for-entities),  \n   [Using classes](#using-classes-for-entities),  \n   [Typescript usage](#usage-with-typescript),  \n   [Working with secure server](#working-with-a-secure-server),  \n   [Building \u0026 running tests](#building)  \n\n* For more information go to the online [RavenDB Documentation](https://ravendb.net/docs/article-page/latest/nodejs/client-api/what-is-a-document-store).\n\n## Getting started\n\n1. Require the `DocumentStore` class from the ravendb package\n```javascript\nconst { DocumentStore } = require('ravendb');\n```\nor (using ES6 / Typescript imports)\n```javascript\nimport { DocumentStore } from 'ravendb';\n```\n\n2. Initialize the document store (you should have a single DocumentStore instance per application)\n```javascript\nconst store = new DocumentStore('http://live-test.ravendb.net', 'databaseName');\nstore.initialize();\n```\n\n3. Open a session\n```javascript\nconst session = store.openSession();\n```\n\n4. Call `saveChanges()` when you're done\n```javascript\nsession\n .load('users/1-A') // Load document\n .then((user) =\u003e {\n   user.password = PBKDF2('new password'); // Update data \n })\n .then(() =\u003e session.saveChanges()) // Save changes\n .then(() =\u003e {\n     // Data is now persisted\n     // You can proceed e.g. finish web request\n  });\n```\n\n5. When you have finished using the session and the document store objects,  \nmake sure to dispose of them properly to free up resources:  \n```javascript\nsession.dispose();\nstore.dispose();\n```\n\n## Supported asynchronous call types\n\nMost methods on the session object are asynchronous and return a Promise.  \nEither use `async \u0026 await` or `.then()` with callback functions.\n\n1. async / await\n```javascript\nconst session = store.openSession();\nlet user = await session.load('users/1-A');\nuser.password = PBKDF2('new password');\nawait session.saveChanges();\n```\n\n2. .then \u0026 callback functions\n```javascript\nsession.load('Users/1-A')\n    .then((user) =\u003e {\n        user.password = PBKDF2('new password');\n    })\n    .then(() =\u003e session.saveChanges())\n    .then(() =\u003e {\n        // here session is complete\n    });\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[async and await](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L55)\u003c/small\u003e  \n\u003e \u003csmall\u003e[then and callbacks](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L72)\u003c/small\u003e\n\n## CRUD example\n\n### Store documents\n\n```javascript\nlet product = {\n    id: null,\n    title: 'iPhone X',\n    price: 999.99,\n    currency: 'USD',\n    storage: 64,\n    manufacturer: 'Apple',\n    in_stock: true,\n    last_update: new Date('2017-10-01T00:00:00')\n};\n\nawait session.store(product, 'products/1-A');\nconsole.log(product.id); // products/1-A\nawait session.saveChanges();\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[store()](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/SessionApiTests.ts#L21)\u003c/small\u003e  \n\u003e \u003csmall\u003e[ID generation - session.store()](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/IdGeneration.ts#L9)\u003c/small\u003e  \n\u003e \u003csmall\u003e[store document with @metadata](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Issues/RDBC_213.ts#L16)\u003c/small\u003e  \n\u003e \u003csmall\u003e[storing docs with same ID in same session should throw](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/TrackEntityTest.ts#L62)\u003c/small\u003e\n\n### Load documents\n\n```javascript\nconst product = await session.load('products/1-A');\nconsole.log(product.title); // iPhone X\nconsole.log(product.id);    // products/1-A\n```\n\n\u003e ##### Related tests:\n\u003e \u003csmall\u003e[load()](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/SessionApiTests.ts#L64)\u003c/small\u003e\n\n### Load documents with include\n\n```javascript\n// users/1\n// {\n//      \"name\": \"John\",\n//      \"kids\": [\"users/2\", \"users/3\"]\n// }\n\nconst session = store.openSession();\nconst user1 = await session\n    .include(\"kids\")\n    .load(\"users/1\");\n    // Document users/1 and all docs referenced in \"kids\"\n    // will be fetched from the server in a single request.\n\nconst user2 = await session.load(\"users/2\"); // this won't call server again\n\nassert.ok(user1);\nassert.ok(user2);\nassert.equal(session.advanced.numberOfRequests, 1);\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[can load with includes](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Documents/LoadTest.ts#L29)\u003c/small\u003e  \n\u003e \u003csmall\u003e[loading data with include](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L128)\u003c/small\u003e  \n\u003e \u003csmall\u003e[loading data with passing includes](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L148)\u003c/small\u003e\n\n### Update documents\n\n```javascript\nlet product = await session.load('products/1-A');\nproduct.in_stock = false;\nproduct.last_update = new Date();\nawait session.saveChanges();\n// ...\nproduct = await session.load('products/1-A');\nconsole.log(product.in_stock);    // false\nconsole.log(product.last_update); // the current date\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[update document](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L170)\u003c/small\u003e  \n\u003e \u003csmall\u003e[update document metadata](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Issues/RDBC_213.ts#L35)\u003c/small\u003e\n\n### Delete documents\n\n1. Using entity\n```javascript\nlet product = await session.load('products/1-A');\nawait session.delete(product);\nawait session.saveChanges();\n\nproduct = await session.load('products/1-A');\nconsole.log(product); // null\n```\n\n2. Using document ID\n```javascript\nawait session.delete('products/1-A');\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[delete doc by entity](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/DeleteTest.ts#L20)\u003c/small\u003e  \n\u003e \u003csmall\u003e[delete doc by ID](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/DeleteTest.ts#L38)\u003c/small\u003e  \n\u003e \u003csmall\u003e[onBeforeDelete is called before delete by ID](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Issues/RavenDB_15492.ts#L16)\u003c/small\u003e  \n\u003e \u003csmall\u003e[cannot delete untracked entity](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/TrackEntityTest.ts#L20)\u003c/small\u003e  \n\u003e \u003csmall\u003e[loading deleted doc returns null](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/TrackEntityTest.ts#L32)\u003c/small\u003e\n\n## Query documents\n\n1. Use `query()` session method:  \n\nQuery by collection:  \n```javascript\nconst query = session.query({ collection: 'products' });\n```\nQuery by index name:  \n```javascript\nconst query = session.query({ indexName: 'productsByCategory' });\n```\nQuery by index:  \n```javascript\nconst query = session.query(Product, Product_ByName);\n```\nQuery by entity type:  \n```javascript\nimport { User } from \"./models\";\nconst query = session.query(User);\n```\n\n2. Build up the query - apply search conditions, set ordering, etc.  \n   Query supports chaining calls:\n```javascript\nquery\n    .waitForNonStaleResults()\n    .usingDefaultOperator('AND')\n    .whereEquals('manufacturer', 'Apple')\n    .whereEquals('in_stock', true)\n    .whereBetween('last_update', new Date('2022-11-01T00:00:00'), new Date())\n    .orderBy('price');\n```\n\n3. Execute the query to get results:\n```javascript\nconst results = await query.all(); // get all results\n// ...\nconst firstResult = await query.first(); // gets first result\n// ...\nconst single = await query.single();  // gets single result \n```\n\n### Query methods overview\n\n#### selectFields() - projections using a single field\n```javascript\n// RQL\n// from users select name\n\n// Query\nconst userNames = await session.query({ collection: \"users\" })\n    .selectFields(\"name\")\n    .all();\n\n// Sample results\n// John, Stefanie, Thomas\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[projections single field](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L341)\u003c/small\u003e  \n\u003e \u003csmall\u003e[query single property](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/QueryTest.ts#L231)\u003c/small\u003e  \n\u003e \u003csmall\u003e[retrieve camel case with projection](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/CustomKeyCaseConventionsTests.ts#L288)\u003c/small\u003e  \n\u003e \u003csmall\u003e[can_project_id_field](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Issues/RavenDB_14811.ts#L58)\u003c/small\u003e  \n\n#### selectFields() - projections using multiple fields\n```javascript\n// RQL\n// from users select name, age\n\n// Query\nawait session.query({ collection: \"users\" })\n    .selectFields([ \"name\", \"age\" ])\n    .all();\n\n// Sample results\n// [ { name: 'John', age: 30 },\n//   { name: 'Stefanie', age: 25 },\n//   { name: 'Thomas', age: 25 } ]\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[projections multiple fields](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L349)\u003c/small\u003e  \n\u003e \u003csmall\u003e[query with projection](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/QueryTest.ts#L318)\u003c/small\u003e  \n\u003e \u003csmall\u003e[retrieve camel case with projection](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/CustomKeyCaseConventionsTests.ts#L288)\u003c/small\u003e  \n\u003e \u003csmall\u003e[can_project_id_field](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Issues/RavenDB_14811.ts#L58)\u003c/small\u003e  \n\n#### distinct()\n```javascript\n// RQL\n// from users select distinct age\n\n// Query\nawait session.query({ collection: \"users\" })\n    .selectFields(\"age\")\n    .distinct()\n    .all();\n\n// Sample results\n// [ 30, 25 ]\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[distinct](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L360)\u003c/small\u003e  \n\u003e \u003csmall\u003e[query distinct](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/QueryTest.ts#L350)\u003c/small\u003e\n\n#### whereEquals() / whereNotEquals()\n```javascript\n// RQL\n// from users where age = 30 \n\n// Query\nawait session.query({ collection: \"users\" })\n    .whereEquals(\"age\", 30)\n    .all();\n\n// Saple results\n// [ User {\n//    name: 'John',\n//    age: 30,\n//    kids: [...],\n//    registeredAt: 2017-11-10T23:00:00.000Z } ]\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[where equals](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L369)\u003c/small\u003e  \n\u003e \u003csmall\u003e[where not equals](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/QueryTest.ts#L451)\u003c/small\u003e\n\n#### whereIn()\n```javascript\n// RQL\n// from users where name in (\"John\", \"Thomas\")\n\n// Query\nawait session.query({ collection: \"users\" })\n    .whereIn(\"name\", [\"John\", \"Thomas\"])\n    .all();\n\n// Sample results\n// [ User {\n//     name: 'John',\n//     age: 30,\n//     registeredAt: 2017-11-10T23:00:00.000Z,\n//     kids: [...],\n//     id: 'users/1-A' },\n//   User {\n//     name: 'Thomas',\n//     age: 25,\n//     registeredAt: 2016-04-24T22:00:00.000Z,\n//     id: 'users/3-A' } ]\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[where in](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L377)\u003c/small\u003e  \n\u003e \u003csmall\u003e[query with where in](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/QueryTest.ts#L256)\u003c/small\u003e\n\n\n#### whereStartsWith() / whereEndsWith()\n```javascript\n// RQL\n// from users where startsWith(name, 'J')\n\n// Query\nawait session.query({ collection: \"users\" })\n    .whereStartsWith(\"name\", \"J\")\n    .all();\n\n// Sample results\n// [ User {\n//    name: 'John',\n//    age: 30,\n//    kids: [...],\n//    registeredAt: 2017-11-10T23:00:00.000Z } ]\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[query with where clause](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/QueryTest.ts#L148)\u003c/small\u003e\n\n#### whereBetween()\n```javascript\n// RQL\n// from users where registeredAt between '2016-01-01' and '2017-01-01'\n\n// Query\nawait session.query({ collection: \"users\" })\n    .whereBetween(\"registeredAt\", new Date(2016, 0, 1), new Date(2017, 0, 1))\n    .all();\n\n// Sample results\n// [ User {\n//     name: 'Thomas',\n//     age: 25,\n//     registeredAt: 2016-04-24T22:00:00.000Z,\n//     id: 'users/3-A' } ]\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[where between](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L385)\u003c/small\u003e  \n\u003e \u003csmall\u003e[query with where between](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/QueryTest.ts#L265)\u003c/small\u003e\n\n#### whereGreaterThan() / whereGreaterThanOrEqual() / whereLessThan() / whereLessThanOrEqual()\n```javascript\n// RQL\n// from users where age \u003e 29\n\n// Query\nawait session.query({ collection: \"users\" })\n    .whereGreaterThan(\"age\", 29)\n    .all();\n\n// Sample results\n// [ User {\n//   name: 'John',\n//   age: 30,\n//   registeredAt: 2017-11-10T23:00:00.000Z,\n//   kids: [...],\n//   id: 'users/1-A' } ]\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[where greater than](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L393)\u003c/small\u003e  \n\u003e \u003csmall\u003e[query with where less than](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/QueryTest.ts#L275)\u003c/small\u003e  \n\u003e \u003csmall\u003e[query with where less than or equal](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/QueryTest.ts#L285)\u003c/small\u003e  \n\u003e \u003csmall\u003e[query with where greater than](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/QueryTest.ts#L294)\u003c/small\u003e  \n\u003e \u003csmall\u003e[query with where greater than or equal](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/QueryTest.ts#L304)\u003c/small\u003e  \n\n#### whereExists()\nChecks if the field exists.\n```javascript\n// RQL\n// from users where exists(\"age\")\n\n// Query\nawait session.query({ collection: \"users\" })\n    .whereExists(\"kids\")\n    .all();\n\n// Sample results\n// [ User {\n//   name: 'John',\n//   age: 30,\n//   registeredAt: 2017-11-10T23:00:00.000Z,\n//   kids: [...],\n//   id: 'users/1-A' } ]\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[where exists](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L401)\u003c/small\u003e  \n\u003e \u003csmall\u003e[query where exists](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/QueryTest.ts#L503)\u003c/small\u003e\n\n#### containsAny() / containsAll()\n```javascript\n// RQL\n// from users where kids in ('Mara')\n\n// Query\nawait session.query({ collection: \"users\" })\n    .containsAll(\"kids\", [\"Mara\", \"Dmitri\"])\n    .all();\n\n// Sample results\n// [ User {\n//   name: 'John',\n//   age: 30,\n//   registeredAt: 2017-11-10T23:00:00.000Z,\n//   kids: [\"Dmitri\", \"Mara\"]\n//   id: 'users/1-A' } ]\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[where contains any](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L409)\u003c/small\u003e  \n\u003e \u003csmall\u003e[queries with contains](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/ContainsTest.ts#L19)\u003c/small\u003e\n\n#### search()\nPerform full-text search.\n```javascript\n// RQL\n// from users where search(kids, 'Mara')\n\n// Query\nawait session.query({ collection: \"users\" })\n    .search(\"kids\", \"Mara Dmitri\")\n    .all();\n\n// Sample results\n// [ User {\n//   name: 'John',\n//   age: 30,\n//   registeredAt: 2017-11-10T23:00:00.000Z,\n//   kids: [\"Dmitri\", \"Mara\"]\n//   id: 'users/1-A' } ]\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[search()](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L417)\u003c/small\u003e  \n\u003e \u003csmall\u003e[query search with or](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/QueryTest.ts#L362)\u003c/small\u003e  \n\u003e \u003csmall\u003e[query_CreateClausesForQueryDynamicallyWithOnBeforeQueryEvent](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/QueryTest.ts#L30)\u003c/small\u003e  \n\n#### openSubclause() / closeSubclause()\n```javascript\n// RQL\n// from users where exists(kids) or (age = 25 and name != Thomas)\n\n// Query\nawait session.query({ collection: \"users\" })\n    .whereExists(\"kids\")\n    .orElse()\n    .openSubclause()\n        .whereEquals(\"age\", 25)\n        .whereNotEquals(\"name\", \"Thomas\")\n    .closeSubclause()\n    .all();\n\n// Sample results\n// [ User {\n//     name: 'John',\n//     age: 30,\n//     registeredAt: 2017-11-10T23:00:00.000Z,\n//     kids: [\"Dmitri\", \"Mara\"]\n//     id: 'users/1-A' },\n//   User {\n//     name: 'Stefanie',\n//     age: 25,\n//     registeredAt: 2015-07-29T22:00:00.000Z,\n//     id: 'users/2-A' } ]\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[subclause](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L425)\u003c/small\u003e  \n\u003e \u003csmall\u003e[working with subclause](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Issues/RavenDB_5669.ts#L40)\u003c/small\u003e\n\n#### not()\n```javascript\n// RQL\n// from users where age != 25\n\n// Query\nawait session.query({ collection: \"users\" })\n    .not()\n    .whereEquals(\"age\", 25)\n    .all();\n\n// Sample results\n// [ User {\n//   name: 'John',\n//   age: 30,\n//   registeredAt: 2017-11-10T23:00:00.000Z,\n//   kids: [\"Dmitri\", \"Mara\"]\n//   id: 'users/1-A' } ]\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[not()](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L438)\u003c/small\u003e  \n\u003e \u003csmall\u003e[query where not](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/QueryTest.ts#L451)\u003c/small\u003e\n\n#### orElse() / andAlso()\n```javascript\n// RQL\n// from users where exists(kids) or age \u003c 30\n\n// Query\nawait session.query({ collection: \"users\" })\n    .whereExists(\"kids\")\n    .orElse()\n    .whereLessThan(\"age\", 30)\n    .all();\n\n// Sample results\n//  [ User {\n//     name: 'John',\n//     age: 30,\n//     registeredAt: 2017-11-10T23:00:00.000Z,\n//     kids: [ 'Dmitri', 'Mara' ],\n//     id: 'users/1-A' },\n//   User {\n//     name: 'Thomas',\n//     age: 25,\n//     registeredAt: 2016-04-24T22:00:00.000Z,\n//     id: 'users/3-A' },\n//   User {\n//     name: 'Stefanie',\n//     age: 25,\n//     registeredAt: 2015-07-29T22:00:00.000Z,\n//     id: 'users/2-A' } ]\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[orElse](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L447)\u003c/small\u003e  \n\u003e \u003csmall\u003e[working with subclause](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Issues/RavenDB_5669.ts#L40)\u003c/small\u003e\n\n#### usingDefaultOperator()\nIf neither `andAlso()` nor `orElse()` is called then the default operator between the query filtering conditions will be `AND` .  \nYou can override that with `usingDefaultOperator` which must be called before any other where conditions.\n```javascript\n// RQL\n// from users where exists(kids) or age \u003c 29\n\n// Query\nawait session.query({ collection: \"users\" })\n    .usingDefaultOperator(\"OR\") // override the default 'AND' operator\n    .whereExists(\"kids\")\n    .whereLessThan(\"age\", 29)\n    .all();\n\n// Sample results\n//  [ User {\n//     name: 'John',\n//     age: 30,\n//     registeredAt: 2017-11-10T23:00:00.000Z,\n//     kids: [ 'Dmitri', 'Mara' ],\n//     id: 'users/1-A' },\n//   User {\n//     name: 'Thomas',\n//     age: 25,\n//     registeredAt: 2016-04-24T22:00:00.000Z,\n//     id: 'users/3-A' },\n//   User {\n//     name: 'Stefanie',\n//     age: 25,\n//     registeredAt: 2015-07-29T22:00:00.000Z,\n//     id: 'users/2-A' } ]\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[set default operator](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L457)\u003c/small\u003e  \n\u003e \u003csmall\u003e[AND is used when default operator is not set](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Issues/RDBC_649.ts#L36)\u003c/small\u003e  \n\u003e \u003csmall\u003e[set default operator to OR](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Issues/RDBC_649.ts#L45)\u003c/small\u003e  \n\n#### orderBy() / orderByDesc() / orderByScore() / randomOrdering()\n```javascript\n// RQL\n// from users order by age\n\n// Query\nawait session.query({ collection: \"users\" })\n    .orderBy(\"age\")\n    .all();\n\n// Sample results\n// [ User {\n//     name: 'Stefanie',\n//     age: 25,\n//     registeredAt: 2015-07-29T22:00:00.000Z,\n//     id: 'users/2-A' },\n//   User {\n//     name: 'Thomas',\n//     age: 25,\n//     registeredAt: 2016-04-24T22:00:00.000Z,\n//     id: 'users/3-A' },\n//   User {\n//     name: 'John',\n//     age: 30,\n//     registeredAt: 2017-11-10T23:00:00.000Z,\n//     kids: [ 'Dmitri', 'Mara' ],\n//     id: 'users/1-A' } ]\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[orderBy()](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L467)\u003c/small\u003e  \n\u003e \u003csmall\u003e[orderByDesc()](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L477)\u003c/small\u003e  \n\u003e \u003csmall\u003e[query random order](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/QueryTest.ts#L451)\u003c/small\u003e  \n\u003e \u003csmall\u003e[order by AlphaNumeric](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/QueryTest.ts#L548)\u003c/small\u003e  \n\u003e \u003csmall\u003e[query with boost - order by score](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/QueryTest.ts#L517)\u003c/small\u003e\n\n#### take()\nLimit the number of query results.\n```javascript\n// RQL\n// from users order by age\n\n// Query\nawait session.query({ collection: \"users\" })\n    .orderBy(\"age\") \n    .take(2) // only the first 2 entries will be returned\n    .all();\n\n// Sample results\n// [ User {\n//     name: 'Stefanie',\n//     age: 25,\n//     registeredAt: 2015-07-29T22:00:00.000Z,\n//     id: 'users/2-A' },\n//   User {\n//     name: 'Thomas',\n//     age: 25,\n//     registeredAt: 2016-04-24T22:00:00.000Z,\n//     id: 'users/3-A' } ]\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[take()](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L487)\u003c/small\u003e  \n\u003e \u003csmall\u003e[query skip take](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/QueryTest.ts#L385)\u003c/small\u003e  \n\u003e \u003csmall\u003e[canUseOffsetWithCollectionQuery](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Issues/RavenDB_17551.ts#L17)\u003c/small\u003e\n\n#### skip()\nSkip a specified number of results from the start.\n```javascript\n// RQL\n// from users order by age\n\n// Query\nawait session.query({ collection: \"users\" })\n    .orderBy(\"age\") \n    .take(1) // return only 1 result\n    .skip(1) // skip the first result, return the second result\n    .all();\n\n// Sample results\n// [ User {\n//     name: 'Thomas',\n//     age: 25,\n//     registeredAt: 2016-04-24T22:00:00.000Z,\n//     id: 'users/3-A' } ]\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[skip()](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L496)\u003c/small\u003e  \n\u003e \u003csmall\u003e[query skip take](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/QueryTest.ts#L385)\u003c/small\u003e  \n\u003e \u003csmall\u003e[canUseOffsetWithCollectionQuery](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Issues/RavenDB_17551.ts#L17)\u003c/small\u003e  \n\n#### Getting query statistics\nUse the `statistics()` method to obtain query statistics.  \n```javascript\n// Query\nlet stats: QueryStatistics;\nconst results = await session.query({ collection: \"users\" })\n    .whereGreaterThan(\"age\", 29)\n    .statistics(s =\u003e stats = s)\n    .all();\n\n// Sample results\n// QueryStatistics {\n//   isStale: false,\n//   durationInMs: 744,\n//   totalResults: 1,\n//   skippedResults: 0,\n//   timestamp: 2018-09-24T05:34:15.260Z,\n//   indexName: 'Auto/users/Byage',\n//   indexTimestamp: 2018-09-24T05:34:15.260Z,\n//   lastQueryTime: 2018-09-24T05:34:15.260Z,\n//   resultEtag: 8426908718162809000 }\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[can get stats](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L506)\u003c/small\u003e  \n\n#### all() / first() / single() / count()\n`all()` - returns all results\n\n`first()` - first result only\n\n`single()` - first result, throws error if there's more entries\n\n`count()` - returns the number of entries in the results (not affected by `take()`)\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[query first and single](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/QueryTest.ts#L467)\u003c/small\u003e  \n\u003e \u003csmall\u003e[query count](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/QueryTest.ts#L834)\u003c/small\u003e\n\n## Attachments\n\n#### Store attachments\n```javascript\nconst doc = new User({ name: \"John\" });\n\n// Store a dcoument, the entity will be tracked.\nawait session.store(doc);\n\n// Get read stream or buffer to store\nconst fileStream = fs.createReadStream(\"../photo.png\");\n\n// Store attachment using entity\nsession.advanced.attachments.store(doc, \"photo.png\", fileStream, \"image/png\");\n\n// OR store attachment using document ID\nsession.advanced.attachments.store(doc.id, \"photo.png\", fileStream, \"image/png\");\n\n// Persist all changes\nawait session.saveChanges();\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[store attachment](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L203)\u003c/small\u003e  \n\u003e \u003csmall\u003e[can put attachments](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Attachments/AttachmentsSessionTest.ts#L26)\u003c/small\u003e  \n\u003e \u003csmall\u003e[checkIfHasChangesIsTrueAfterAddingAttachment](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Issues/RavenDB_16985.ts#L17)\u003c/small\u003e  \n\u003e \u003csmall\u003e[store many attachments and docs with bulk insert](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Attachments/BulkInsertAttachmentsTest.ts#L105)\u003c/small\u003e\n\n#### Get attachments\n```javascript\n// Get an attachment\nconst attachment = await session.advanced.attachments.get(documentId, \"photo.png\")\n\n// Attachment.details contains information about the attachment:\n//     { \n//       name: 'photo.png',\n//       documentId: 'users/1-A',\n//       contentType: 'image/png',\n//       hash: 'MvUEcrFHSVDts5ZQv2bQ3r9RwtynqnyJzIbNYzu1ZXk=',\n//       changeVector: '\"A:3-K5TR36dafUC98AItzIa6ow\"',\n//       size: 4579 \n//     }\n\n// Attachment.data is a Readable. See https://nodejs.org/api/stream.html#class-streamreadable\nattachment.data\n    .pipe(fs.createWriteStream(\"photo.png\"))\n    .on(\"finish\", () =\u003e next());\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[get attachment](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L241)\u003c/small\u003e  \n\u003e \u003csmall\u003e[can get \u0026 delete attachments](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Attachments/AttachmentsSessionTest.ts#L133)\u003c/small\u003e\n\n#### Check if attachment exists\n```javascript\nawait session.advanced.attachments.exists(doc.id, \"photo.png\");\n// true\n\nawait session.advanced.attachments.exists(doc.id, \"not_there.avi\");\n// false\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[attachment exists](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L258)\u003c/small\u003e  \n\u003e \u003csmall\u003e[attachment exists 2](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Attachments/AttachmentsSessionTest.ts#L316)\u003c/small\u003e\n\n#### Get attachment names\n```javascript\n// Use a loaded entity to determine attachments' names\nawait session.advanced.attachments.getNames(doc);\n\n// Sample results:\n// [ { name: 'photo.png',\n//     hash: 'MvUEcrFHSVDts5ZQv2bQ3r9RwtynqnyJzIbNYzu1ZXk=',\n//     contentType: 'image/png',\n//     size: 4579 } ]\n```\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[get attachment names](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L266)\u003c/small\u003e  \n\u003e \u003csmall\u003e[get attachment names 2](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Attachments/AttachmentsSessionTest.ts#L288)\u003c/small\u003e\n\u003e \n## TimeSeries\n\n#### Store time series \n```javascript\nconst session = store.openSession();\n\n// Create a document with time series\nawait session.store({ name: \"John\" }, \"users/1\");\nconst tsf = session.timeSeriesFor(\"users/1\", \"heartbeat\");\n\n// Append a new time series entry\ntsf.append(new Date(), 120);\n\nawait session.saveChanges();\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[can use time series](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L759)\u003c/small\u003e  \n\u003e \u003csmall\u003e[canCreateSimpleTimeSeries](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/TimeSeries/TimeSeriesSessionTest.ts#L18)\u003c/small\u003e  \n\u003e \u003csmall\u003e[usingDifferentTags](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/TimeSeries/TimeSeriesSessionTest.ts#L217)\u003c/small\u003e  \n\u003e \u003csmall\u003e[canStoreAndReadMultipleTimestamps](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/TimeSeries/TimeSeriesSessionTest.ts#L372)\u003c/small\u003e  \n\u003e \u003csmall\u003e[canStoreLargeNumberOfValues](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/TimeSeries/TimeSeriesSessionTest.ts#L430)\u003c/small\u003e  \n\u003e \u003csmall\u003e[shouldDeleteTimeSeriesUponDocumentDeletion](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/TimeSeries/TimeSeriesSessionTest.ts#L729)\u003c/small\u003e\n\n#### Get time series for document\n```javascript\nconst session = store.openSession();\n\n// Get time series for document by time series name\nconst tsf = session.timeSeriesFor(\"users/1\", \"heartbeat\");\n\n// Get all time series entries\nconst heartbeats = await tsf.get();\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[canCreateSimpleTimeSeries](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/TimeSeries/TimeSeriesSessionTest.ts#L18)\u003c/small\u003e  \n\u003e \u003csmall\u003e[canStoreLargeNumberOfValues](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/TimeSeries/TimeSeriesSessionTest.ts#L430)\u003c/small\u003e  \n\u003e \u003csmall\u003e[canRequestNonExistingTimeSeriesRange](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/TimeSeries/TimeSeriesSessionTest.ts#L544)\u003c/small\u003e  \n\u003e \u003csmall\u003e[canGetTimeSeriesNames2](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/TimeSeries/TimeSeriesSessionTest.ts#L648)\u003c/small\u003e  \n\u003e \u003csmall\u003e[canSkipAndTakeTimeSeries](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/TimeSeries/TimeSeriesSessionTest.ts#L772)\u003c/small\u003e\n\n## Bulk Insert\n\n```javascript\n// Create a bulk insert instance from the DocumentStore\nconst bulkInsert = store.bulkInsert();\n\n// Store multiple documents\nfor (const name of [\"Anna\", \"Maria\", \"Miguel\", \"Emanuel\", \"Dayanara\", \"Aleida\"]) {\n    const user = new User({ name });\n    await bulkInsert.store(user);\n    // The data stored in bulkInsert will be streamed to the server in batches \n}\n\n// Sample documents stored:\n// User { name: 'Anna', id: 'users/1-A' }\n// User { name: 'Maria', id: 'users/2-A' }\n// User { name: 'Miguel', id: 'users/3-A' }\n// User { name: 'Emanuel', id: 'users/4-A' }\n// User { name: 'Dayanara', id: 'users/5-A' }\n// User { name: 'Aleida', id: 'users/6-A' }\n\n// Call finish to send all remaining data to the server\nawait bulkInsert.finish();\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[bulk insert example](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L279)\u003c/small\u003e  \n\u003e \u003csmall\u003e[simple bulk insert should work](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/BulkInsert/BulkInsertsTest.ts#L23)\u003c/small\u003e  \n\u003e \u003csmall\u003e[bulk insert can be aborted](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/BulkInsert/BulkInsertsTest.ts#L95)\u003c/small\u003e  \n\u003e \u003csmall\u003e[can modify metadata with bulk insert](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/BulkInsert/BulkInsertsTest.ts#L136)\u003c/small\u003e  \n\n## Changes API\n\nListen for database changes e.g. document changes.\n\n```javascript\n// Subscribe to change notifications\nconst changes = store.changes();\n\n// Subscribe for all documents, or for specific collection (or other database items)\nconst docsChanges = changes.forAllDocuments();\n\n// Handle changes events \ndocsChanges.on(\"data\", change =\u003e {\n    // A sample change data recieved:\n    // { type: 'Put',\n    //   id: 'users/1-A',\n    //   collectionName: 'Users',\n    //   changeVector: 'A:2-QCawZTDbuEa4HUBORhsWYA' }\n});\n\ndocsChanges.on(\"error\", err =\u003e {\n    // handle errors\n})\n\n{\n    const session = store.openSession();\n    await session.store(new User({ name: \"Starlord\" }));\n    await session.saveChanges();\n}\n\n// ...\n// Dispose the changes instance when you're done\nchanges.dispose();\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[listen to changes](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L306)\u003c/small\u003e  \n\u003e \u003csmall\u003e[can obtain single document changes](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Server/Documents/Notifications/ChangesTest.ts#L25)\u003c/small\u003e  \n\u003e \u003csmall\u003e[can obtain all documents changes](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Server/Documents/Notifications/ChangesTest.ts#L93)\u003c/small\u003e  \n\u003e \u003csmall\u003e[can obtain notification about documents starting with](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Server/Documents/Notifications/ChangesTest.ts#L255)\u003c/small\u003e  \n\u003e \u003csmall\u003e[can obtain notification about documents in collection](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Server/Documents/Notifications/ChangesTest.ts#L312)\u003c/small\u003e  \n\n## Streaming\n\n#### Stream documents by ID prefix\n```javascript\n// Filter streamed results by passing an ID prefix\n// The stream() method returns a Node.js ReadableStream\nconst userStream = await session.advanced.stream(\"users/\");\n\n// Handle stream events with callback functions\nuserStream.on(\"data\", user =\u003e {\n    // Get only documents with ID that starts with 'users/' \n    // i.e.: User { name: 'John', id: 'users/1-A' }\n});\n\nuserStream.on(\"error\", err =\u003e {\n    // handle errors\n})\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[can stream users by prefix](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L525)\u003c/small\u003e  \n\u003e \u003csmall\u003e[can stream documents starting with](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Core/Streaming/DocumentStreaming.ts#L39)\u003c/small\u003e  \n\n#### Stream documents by query \n```javascript\n// Define a query\nconst query = session.query({ collection: \"users\" }).whereGreaterThan(\"age\", 29);\n\nlet streamQueryStats;\n// Call stream() to execute the query, it returns a Node.js ReadableStream.\n// Can get query stats by passing a stats callback to stream() method\nconst queryStream = await session.advanced.stream(query, _ =\u003e streamQueryStats = _);\n\n// Handle stream events with callback functions\nqueryStream.on(\"data\", user =\u003e {\n    // Only documents matching the query are received\n    // These entities are Not tracked by the session\n});\n\n// Can get query stats by using an event listener\nqueryStream.once(\"stats\", queryStats =\u003e {\n    // Sample stats:\n    // { resultEtag: 7464021133404493000,\n    //   isStale: false,\n    //   indexName: 'Auto/users/Byage',\n    //   totalResults: 1,\n    //   indexTimestamp: 2018-10-01T09:04:07.145Z }\n});\n\n// Stream emits an 'end' event when there is no more data to read\nqueryStream.on(\"end\", () =\u003e {\n   // Get info from 'streamQueryStats', the stats object\n   const totalResults = streamQueryStats.totalResults;\n   const indexUsed = streamQueryStats.indexName;\n});\n\nqueryStream.on(\"error\", err =\u003e {\n    // handle errors\n});\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[can stream query and get stats](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L546)\u003c/small\u003e  \n\u003e \u003csmall\u003e[can stream query results](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Core/Streaming/QueryStreaming.ts#L76)\u003c/small\u003e  \n\u003e \u003csmall\u003e[can stream query results with query statistics](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Core/Streaming/QueryStreaming.ts#L140)\u003c/small\u003e  \n\u003e \u003csmall\u003e[can stream raw query results](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Core/Streaming/QueryStreaming.ts#L192)\u003c/small\u003e  \n\n## Revisions\n\nNOTE: Please make sure revisions are enabled before trying the below.\n\n```javascript\nconst session = store.openSession();\nconst user = {\n    name: \"Marcin\",\n    age: 30,\n    pet: \"Cat\"\n};\n\n// Store a document\nawait session.store(user, \"users/1\");\nawait session.saveChanges();\n\n// Modify the document to create a new revision\nuser.name = \"Roman\";\nuser.age = 40;\nawait session.saveChanges();\n\n// Get revisions\nconst revisions = await session.advanced.revisions.getFor(\"users/1\");\n\n// Sample results:\n// [ { name: 'Roman',\n//     age: 40,\n//     pet: 'Cat',\n//     '@metadata': [Object],\n//     id: 'users/1' },\n//   { name: 'Marcin',\n//     age: 30,\n//     pet: 'Cat',\n//     '@metadata': [Object],\n//     id: 'users/1' } ]\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[can get revisions](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L737)\u003c/small\u003e  \n\u003e \u003csmall\u003e[canGetRevisionsByDate](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Issues/RavenDB_11770.ts#L21)\u003c/small\u003e  \n\u003e \u003csmall\u003e[can handle revisions](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/RevisionsTest.ts#L35)\u003c/small\u003e  \n\u003e \u003csmall\u003e[canGetRevisionsByChangeVectors](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/RevisionsTest.ts#L149)\u003c/small\u003e  \n\n## Suggestions\n\nSuggest options for similar/misspelled terms\n\n```javascript\n// Some documents in users collection with misspelled name term\n// [ User {\n//     name: 'Johne',\n//     age: 30,\n//     ...\n//     id: 'users/1-A' },\n//   User {\n//     name: 'Johm',\n//     age: 31,\n//     ...\n//     id: 'users/2-A' },\n//   User {\n//     name: 'Jon',\n//     age: 32,\n//     ...\n//     id: 'users/3-A' },\n// ]\n\n// Static index definition\nclass UsersIndex extends AbstractJavaScriptIndexCreationTask {\n    constructor() {\n        super();\n        this.map(User, doc =\u003e {\n            return {\n                name: doc.name\n            }\n        });\n        \n        // Enable the suggestion feature on index-field 'name'\n        this.suggestion(\"name\"); \n    }\n}\n\n// ...\nconst session = store.openSession();\n\n// Query for similar terms to 'John'\n// Note: the term 'John' itself will Not be part of the results\n\nconst suggestedNameTerms = await session.query(User, UsersIndex)\n    .suggestUsing(x =\u003e x.byField(\"name\", \"John\")) \n    .execute();\n\n// Sample results:\n// { name: { name: 'name', suggestions: [ 'johne', 'johm', 'jon' ] } }\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[can suggest](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L581)\u003c/small\u003e  \n\u003e \u003csmall\u003e[canChainSuggestions](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Issues/RavenDB_9584.ts#L19)\u003c/small\u003e  \n\u003e \u003csmall\u003e[canUseAliasInSuggestions](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Issues/RavenDB_9584.ts#L42)\u003c/small\u003e  \n\u003e \u003csmall\u003e[canUseSuggestionsWithAutoIndex](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Issues/RavenDB_9584.ts#L60)\u003c/small\u003e  \n\u003e \u003csmall\u003e[can suggest using linq](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Suggestions/SuggestionsTest.ts#L39)\u003c/small\u003e  \n\u003e \u003csmall\u003e[can suggest using multiple words](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Suggestions/SuggestionsTest.ts#L78)\u003c/small\u003e  \n\u003e \u003csmall\u003e[can get suggestions with options](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Suggestions/SuggestionsTest.ts#L125)\u003c/small\u003e  \n\n## Advanced patching\n\n```javascript\n// Increment 'age' field by 1\nsession.advanced.increment(\"users/1\", \"age\", 1);\n\n// Set 'underAge' field to false\nsession.advanced.patch(\"users/1\", \"underAge\", false);\n\nawait session.saveChanges();\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[can use advanced.patch](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L708)\u003c/small\u003e  \n\u003e \u003csmall\u003e[can patch](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/FirstClassPatchTest.ts#L18)\u003c/small\u003e  \n\u003e \u003csmall\u003e[can patch complex](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/FirstClassPatchTest.ts#L93)\u003c/small\u003e  \n\u003e \u003csmall\u003e[can add to array](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/FirstClassPatchTest.ts#L162)\u003c/small\u003e  \n\u003e \u003csmall\u003e[can increment](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/FirstClassPatchTest.ts#L268)\u003c/small\u003e  \n\u003e \u003csmall\u003e[patchWillUpdateTrackedDocumentAfterSaveChanges](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Issues/RavenDB_11552.ts#L27)\u003c/small\u003e  \n\u003e \u003csmall\u003e[can patch single document](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/PatchTest.ts#L24)\u003c/small\u003e  \n\u003e \u003csmall\u003e[can patch multiple documents](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/PatchTest.ts#L71)\u003c/small\u003e  \n\n## Subscriptions\n\n```javascript\n// Create a subscription task on the server\n// Documents that match the query will be send to the client worker upon opening a connection\n\nconst subscriptionName = await store.subscriptions.create({\n    query: \"from users where age \u003e= 30\"\n});\n\n// Open a connection\n// Create a subscription worker that will consume document batches sent from the server\n// Documents are sent from the last document that was processed for this subscription\n\nconst subscriptionWorker = store.subscriptions.getSubscriptionWorker({ subscriptionName });\n\n// Worker handles incoming batches\nsubscriptionWorker.on(\"batch\", (batch, callback) =\u003e {\n    try {\n        // Process the incoming batch items\n        // Sample batch.items:\n        // [ Item {\n        //     changeVector: 'A:2-r6nkF5nZtUKhcPEk6/LL+Q',\n        //     id: 'users/1-A',\n        //     rawResult:\n        //      { name: 'John',\n        //        age: 30,\n        //        registeredAt: '2017-11-11T00:00:00.0000000',\n        //        kids: [Array],\n        //        '@metadata': [Object],\n        //        id: 'users/1-A' },\n        //     rawMetadata:\n        //      { '@collection': 'Users',\n        //        '@nested-object-types': [Object],\n        //        'Raven-Node-Type': 'User',\n        //        '@change-vector': 'A:2-r6nkF5nZtUKhcPEk6/LL+Q',\n        //        '@id': 'users/1-A',\n        //        '@last-modified': '2018-10-18T11:15:51.4882011Z' },\n        //     exceptionMessage: undefined } ]\n        // ...\n\n        // Call the callback once you're done\n        // The worker will send an acknowledgement to the server, so that server can send next batch\n        callback();\n        \n    } catch(err) {\n        // If processing fails for a particular batch then pass the error to the callback\n        callback(err);\n    }\n});\n\nsubscriptionWorker.on(\"error\", err =\u003e {\n   // handle errors\n});\n\n// Subscription event types: \n'batch', 'error', 'end', 'unexpectedSubscriptionError', 'afterAcknowledgment', 'connectionRetry'\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[can subscribe](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L607)\u003c/small\u003e  \n\u003e \u003csmall\u003e[should stream all documents](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Subscriptions/SubscriptionsBasicTest.ts#L143)\u003c/small\u003e  \n\u003e \u003csmall\u003e[should send all new and modified docs](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Subscriptions/SubscriptionsBasicTest.ts#L202)\u003c/small\u003e  \n\u003e \u003csmall\u003e[should respect max doc count in batch](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Subscriptions/SubscriptionsBasicTest.ts#L263)\u003c/small\u003e  \n\u003e \u003csmall\u003e[can disable subscription](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Subscriptions/SubscriptionsBasicTest.ts#L345)\u003c/small\u003e  \n\u003e \u003csmall\u003e[can delete subscription](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/Subscriptions/SubscriptionsBasicTest.ts#L52)\u003c/small\u003e  \n\n## Using object literals for entities\n\nTo comfortably use object literals as entities,  \nconfigure the collection name that will be used in the store conventions.  \n\nThis must be done *before* calling `initialize()` on the DocumentStore instance,  \nelse, your entities will be created in the *@empty* collection.\n\n```javascript\nconst store = new DocumentStore(urls, database);\n\n// Configure the collection name that will be used\nstore.conventions.findCollectionNameForObjectLiteral = entity =\u003e entity[\"collection\"];\n// ...\nstore.initialize();\n\n// Sample object literal\nconst user = {\n   collection: \"Users\",\n   name: \"John\"\n};\n\nsession = store.openSession();\nawait session.store(user);\nawait session.saveChanges();\n\n// The document will be stored in the 'Users' collection\n```\n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[using object literals for entities](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/ReadmeSamples.ts#L644)\u003c/small\u003e  \n\u003e \u003csmall\u003e[using object literals](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/SessionApiTests.ts#L108)\u003c/small\u003e  \n\u003e \u003csmall\u003e[handle custom entity naming conventions + object literals](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Ported/BulkInsert/BulkInsertsTest.ts#L220)\u003c/small\u003e  \n\n## Using classes for entities\n\n1. Define your model as class. Attributes should be just public properties:\n```javascript\nexport class Product {\n    constructor(\n        id = null,\n        title = '',\n        price = 0,\n        currency = 'USD',\n        storage = 0,\n        manufacturer = '',\n        in_stock = false,\n        last_update = null\n    ) {\n        Object.assign(this, {\n            title,\n            price,\n            currency,\n            storage,\n            manufacturer,\n            in_stock,\n            last_update: last_update || new Date()\n        });\n      }\n}\n```\n\n2. To store a document pass its instance to `store()`.  \n   The collection name will automatically be detected from the entity's class name.  \n```javascript\nimport { Product } from \"./models\"; \n\nlet product = new Product(\n  null, 'iPhone X', 999.99, 'USD', 64, 'Apple', true, new Date('2017-10-01T00:00:00'));\n\nproduct = await session.store(product);\nconsole.log(product instanceof Product);       // true\nconsole.log(product.id.includes('products/')); // true\nawait session.saveChanges();\n```\n\n3. Loading a document  \n```javascript\nconst product = await session.load('products/1-A');\nconsole.log(product instanceof Product); // true\nconsole.log(product.id);                 // products/1-A\n```\n\n4. Querying for documents  \n```javascript\nconst products = await session.query({  collection: 'products' }).all();\n\nproducts.forEach((product) =\u003e {\n  console.log(product instanceof Product);       // true\n  console.log(product.id.includes('products/')); // true\n});\n```  \n\n\u003e##### Related tests:\n\u003e \u003csmall\u003e[using classes](https://github.com/ravendb/ravendb-nodejs-client/blob/5c14565d0c307d22e134530c8d63b09dfddcfb5b/test/Documents/SessionApiTests.ts#L173)\u003c/small\u003e  \n\n## Usage with TypeScript\n\nTypeScript typings are embedded into the package (see `types` property in `package.json`).\n\n```typescript\n// file models/product.ts\nexport class Product {\n  constructor(\n    public id: string = null,\n    public title: string = '',\n    public price: number = 0,\n    public currency: string = 'USD',\n    public storage: number = 0,\n    public manufacturer: string = '',\n    public in_stock: boolean = false,\n    public last_update: Date = null\n  ) {}\n}\n\n// file app.ts\nimport {Product} from \"models/product\";\nimport {DocumentStore, IDocumentStore, IDocumentSession, IDocumentQuery, DocumentConstructor, QueryOperators} from 'ravendb';\n\nconst store: IDocumentStore = new DocumentStore('url', 'database name');\nlet session: IDocumentSession;\n\nstore.initialize();\n\n(async (): Promise\u003cvoid\u003e =\u003e {\n  let product = new Product(\n    null, 'iPhone X', 999.99, 'USD', 64, 'Apple', true, new Date('2017-10-01T00:00:00')\n  );\n\n  await session.store\u003cProduct\u003e(product);\n  await session.saveChanges();\n  console.log(product instanceof Product);       // true\n  console.log(product.id.includes('products/')); // true\n\n  product = await session.load\u003cProduct\u003e('products/1-A');\n  console.log(product instanceof Product); // true\n  console.log(product.id);                 // products/1-A\n\n  let products: Product[] = await session\n    .query\u003cProduct\u003e({ collection: 'Products' })\n    .waitForNonStaleResults()\n    .whereEquals('manufacturer', 'Apple')\n    .whereEquals('in_stock', true)\n    .whereBetween('last_update', new Date('2017-10-01T00:00:00'), new Date())\n    .whereGreaterThanOrEqual('storage', 64)\n    .all();\n\n  products.forEach((product: Product): void =\u003e {\n    console.log(product instanceof Product);       // true\n    console.log(product.id.includes('products/')); // true\n  });\n})();\n```\n\n## Working with a secure server\n\n1. Fill auth options object.  \n   Pass the contents of the pem/pfx certificate, specify its type, and (optionally) a passphrase:\n```javascript\nconst {DocumentStore, Certificate} = require('ravendb');\n\nconst certificate = `\n-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----\n-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----\n`;\n\nlet authOptions = {\n  certificate,\n  type: \"pem\",\n  password: \"my passphrase\" // optional  \n};\n``` \n\nPFX certificates content should be passed as a `Buffer` object:\n\n```javascript\nconst {DocumentStore} = require('ravendb');\nconst fs = require('fs');\n\nconst certificate = './cert.pfx';\n\nlet authOptions = {\n  certificate: fs.readFileSync(certificate),\n  type: \"pfx\",\n  password: 'my passphrase' // optional  \n};\n``` \n\n2. Pass auth options as third argument to `DocumentStore` constructor:\n\n```javascript\nlet store = new DocumentStore('url', 'databaseName', authOptions);\nstore.initialize();\n```\n\n## Building\n\n```bash\nnpm install\nnpm run build\n```\n\n## Running tests\n\n```bash\n# To run the suite, set the following environment variables:\n# \n# - Location of RavenDB server binary:\n# RAVENDB_TEST_SERVER_PATH=\"C:\\\\work\\\\test\\\\Server\\\\Raven.Server.exe\" \n#\n# - Certificate path for tests requiring a secure server:\n# RAVENDB_TEST_SERVER_CERTIFICATE_PATH=\"C:\\\\work\\\\test\\\\cluster.server.certificate.pfx\"\n#\n# - Certificate hostname: \n# RAVENDB_TEST_SERVER_HOSTNAME=\"a.nodejstest.development.run\"\n#\nnpm test \n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fravendb%2Fravendb-nodejs-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fravendb%2Fravendb-nodejs-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fravendb%2Fravendb-nodejs-client/lists"}