{"id":41782395,"url":"https://github.com/dividedbyzeroco/warp-sdk-js","last_synced_at":"2026-01-25T04:04:29.206Z","repository":{"id":95357461,"uuid":"58609955","full_name":"dividedbyzeroco/warp-sdk-js","owner":"dividedbyzeroco","description":"JavaScript SDK for Warp Server","archived":false,"fork":false,"pushed_at":"2018-08-20T06:54:48.000Z","size":499,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-28T03:22:13.704Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dividedbyzeroco.png","metadata":{"files":{"readme":"readme-legacy.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2016-05-12T05:17:28.000Z","updated_at":"2018-08-20T06:54:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"4f185f28-a69d-498c-ab68-38e18f043d7a","html_url":"https://github.com/dividedbyzeroco/warp-sdk-js","commit_stats":{"total_commits":390,"total_committers":5,"mean_commits":78.0,"dds":0.5564102564102564,"last_synced_commit":"384b724b797e58fdbf38bff6df8a90e2b6a8ce98"},"previous_names":["jakejosol/warp-sdk-js"],"tags_count":63,"template":false,"template_full_name":null,"purl":"pkg:github/dividedbyzeroco/warp-sdk-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dividedbyzeroco%2Fwarp-sdk-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dividedbyzeroco%2Fwarp-sdk-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dividedbyzeroco%2Fwarp-sdk-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dividedbyzeroco%2Fwarp-sdk-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dividedbyzeroco","download_url":"https://codeload.github.com/dividedbyzeroco/warp-sdk-js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dividedbyzeroco%2Fwarp-sdk-js/sbom","scorecard":{"id":345307,"data":{"date":"2025-08-11","repo":{"name":"github.com/dividedbyzeroco/warp-sdk-js","commit":"384b724b797e58fdbf38bff6df8a90e2b6a8ce98"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.3,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"113 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-6chw-6frg-f759","Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx","Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw","Warn: Project is vulnerable to: GHSA-c6rq-rjc2-86v2","Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-9vvw-cc9w-f27h","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-hr2v-3952-633q","Warn: Project is vulnerable to: GHSA-ff7x-qrg7-qggm","Warn: Project is vulnerable to: GHSA-phwq-j96m-2c2q","Warn: Project is vulnerable to: GHSA-ghr5-ch3p-vcr6","Warn: Project is vulnerable to: GHSA-vh7m-p724-62c2","Warn: Project is vulnerable to: GHSA-r9p9-mrjm-926w","Warn: Project is vulnerable to: GHSA-434g-2637-qmqr","Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m","Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw","Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p","Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747","Warn: Project is vulnerable to: GHSA-vjh7-7g9h-fjfh","Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc","Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx","Warn: Project is vulnerable to: GHSA-qrmc-fj45-qfc2","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3","Warn: Project is vulnerable to: MAL-2023-462","Warn: Project is vulnerable to: GHSA-xf7w-r453-m56c","Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5","Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97","Warn: Project is vulnerable to: GHSA-44pw-h2cw-w3vq","Warn: Project is vulnerable to: GHSA-jp4x-w63m-7wgm","Warn: Project is vulnerable to: GHSA-c429-5p7v-vgjp","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-2pr6-76vf-7546","Warn: Project is vulnerable to: GHSA-8j8c-7jfh-h6hx","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp","Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq","Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488","Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g","Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574","Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm","Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-pp57-mqmh-44h7","Warn: Project is vulnerable to: GHSA-4xcv-9jjx-gfj3","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-fhjf-83wg-r2j9","Warn: Project is vulnerable to: GHSA-8hfj-j24r-96c4","Warn: Project is vulnerable to: GHSA-wc69-rhjr-hc9g","Warn: Project is vulnerable to: GHSA-56x4-j7p9-fcf9","Warn: Project is vulnerable to: GHSA-v78c-4p63-2j6c","Warn: Project is vulnerable to: GHSA-w7rc-rwvf-8q5r","Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g","Warn: Project is vulnerable to: GHSA-3j8f-xvm3-ffx4","Warn: Project is vulnerable to: GHSA-4p35-cfcx-8653","Warn: Project is vulnerable to: GHSA-7f3x-x4pr-wqhj","Warn: Project is vulnerable to: GHSA-jpp7-7chh-cf67","Warn: Project is vulnerable to: GHSA-q6wq-5p59-983w","Warn: Project is vulnerable to: GHSA-j9fq-vwqv-2fm2","Warn: Project is vulnerable to: GHSA-pqw5-jmp5-px4v","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j","Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w","Warn: Project is vulnerable to: GHSA-g6ww-v8xp-vmwg","Warn: Project is vulnerable to: GHSA-h7cp-r72f-jxh6","Warn: Project is vulnerable to: GHSA-v62p-rq8g-8h59","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-6g33-f262-xjp4","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg","Warn: Project is vulnerable to: GHSA-h9rv-jmmf-4pgx","Warn: Project is vulnerable to: GHSA-hxcc-f52p-wc94","Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p","Warn: Project is vulnerable to: GHSA-4g88-fppr-53pp","Warn: Project is vulnerable to: GHSA-4jqc-8m5r-9rpr","Warn: Project is vulnerable to: GHSA-4rq4-32rv-6wp6","Warn: Project is vulnerable to: GHSA-64g7-mvw6-v9qj","Warn: Project is vulnerable to: GHSA-2m39-62fm-q8r3","Warn: Project is vulnerable to: GHSA-vx3p-948g-6vhq","Warn: Project is vulnerable to: GHSA-mf6x-7mm4-x2g7","Warn: Project is vulnerable to: GHSA-j44m-qm6p-hp7m","Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9","Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-g7q5-pjjr-gqvp","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-332q-7ff2-57h2","Warn: Project is vulnerable to: GHSA-cf4h-3jhx-xvhq","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp","Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw","Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc","Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-18T06:54:35.003Z","repository_id":95357461,"created_at":"2025-08-18T06:54:35.004Z","updated_at":"2025-08-18T06:54:35.004Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28742983,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T02:46:29.005Z","status":"ssl_error","status_checked_at":"2026-01-25T02:44:29.968Z","response_time":113,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2026-01-25T04:04:28.515Z","updated_at":"2026-01-25T04:04:29.199Z","avatar_url":"https://github.com/dividedbyzeroco.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Warp JavaScript SDK\n===================\n\n__The Warp JS SDK__ is a library for implementing the Warp Framework using JavaScript. It is designed to work with projects built on-top of the **[Warp Server](http://github.com/dividedbyzeroco/warp-server)**.\n\n## Table of Contents\n- **[Installation](#installation)**  \n- **[Configuration](#configuration)**\n- **[Objects](#objects)**\n    - **[Saving Objects](#saving-objects)**\n    - **[Retrieving Objects](#retrieving-objects)**\n    - **[Updating Objects](#updating-objects)**\n    - **[Deleting Objects](#deleting-objects)**\n    - **[Pointers](#pointers)**\n    - **[Files](#files)**\n    - **[Subclasses](#subclasses)**\n- **[Queries](#queries)**\n    - **[Constraints](#constraints)**\n    - **[Subqueries](#subqueries)**\n    - **[Limit](#limit)**\n    - **[Sorting](#sorting)**\n    - **[Including Pointer Keys](#including-pointer-keys)**\n- **[Collections](#collections)**\n    - **[Counting Collections](#counting-collections)**\n    - **[Filtering Collections](#filtering-collections)**\n    - **[Sorting Collections](#sorting-collections)**\n    - **[Manipulating Collections](#manipulating-collections)**\n    - **[Converting Collections](#converting-collections)**\n    - **[Chaining Methods](#chaining-methods)**\n- **[Users](#users)**\n    - **[Getting Special User Keys](#getting-special-user-keys)**\n    - **[Logging In](#logging-in)**\n    - **[Fetching Current User](#fetching-current-user)**\n    - **[Signing Up](#signing-up)**\n    - **[Logging Out](#logging-out)**\n- **[Functions](#functions)**\n    \n## Installation\n\nTo install the Warp JS SDK via npm, simply use the install command to save it in your package.json:\n\n```javascript\nnpm install --save warp-sdk-js\n```\n\n## Configuration\n\nTo initialize the SDK for **client-side development**, simply add the following configruation to the main file of your project:\n\n```javascript\n// Require Warp\nvar Warp = require('warp-sdk-js');\n\n// Initialize Warp\nWarp.initialize({ apiKey: '12345678abcdefg', baseURL: 'http://my-warp-server.com/api/1' });\n```\n\nOr, if you are going to use the SDK for **server-side development** on `Warp Server` (ex. `Warp Functions`, `Warp Queues`, or `Warp Models`), simply use the `Warp` property of your `Warp Server` instance:\n\n```javascript\n// Instantiate Warp Server\nvar api = new WarpServer(/* configuration */);\n\n// Set up the Warp Server router for express\nvar app = express();\napp.use('/api/1', api.router());\n\n// Get the Warp SDK directly from the api instance\nvar Warp = api.Warp;\n```\n\nCOMING SOON: **server-side development** outside of `Warp Server`\n\n## Objects\n\nObjects represent individual instances of models. In terms of the database, an Object can be thought of as being a `row` in a table. Throughout the Warp Framework, Objects are the basic vehicles for data to be transmitted to and fro the server.\n\nEach Object contains different keys which can be set or retrieved as needed. Among these keys are three special ones:\n\n- id: a unique identifier that distinguishes an object inside a table\n- created_at: a timestamp that records the date and time when a particular object was created (UTC)\n- updated_at: a timestamp that records the date and time when a particular object was last modified (UTC)\n\nThese keys are specifically set by the server and cannot be modified by the user.\n\n\n### Saving Objects\n\nTo save an Object for a specific model, use the `Warp.Object` class:\n\n```javascript\nvar alien = new Warp.Object('alien');\n```\n\nYou can set the values of the Object's keys using the `.set()` method:\n\n```javascript\nalien.set('name', 'The Doctor');\nalien.set('age', 150000);\nalien.set('type', 4);\n```\n\nThen, save the Object using the `.save()` method:\n\n```javascript\nalien.save();\n```\n\nAdditionally, the `.save()` method returns a promise, which you can chain other processes to:\n\n```javascript\nalien.save().then(function() {\n    alert('The alien has been created with the following ID: ' + alien.id);\n    alert('The alien has been named: ' + alien.get('name'));\n});\n\n// or\n\nalien.save(function() {\n    alert('The alien has been created at: ' + alien.createdAt);\n    alert('The alien has been updated at: ' + alien.updatedAt);\n});\n```\n\n\n### Retrieving Objects\n\nTo retrieve an Object for a specific model, you can use `Warp Queries`. For more info, see the section on [Queries](#queries):\n\n```javascript\nvar alienQuery = new Warp.Query('alien');\nalienQuery.equalTo('id', 16);\nalienQuery.first().then(function(alien) {\n    // You now have a copy of alien (id: 16) from the database\n});\n```\n\nNow that you have fetched the object, you can also get its keys using the `.get()` method:\n\n```javascript\nvar name = alien.get('name');\nvar age = alien.get('age');\nvar type = alien.get('type');\n```\n\nFor special keys as mentioned in the section on [Objects](#objects), you can retrieve their values via the following properties:\n\n```javascript\nvar id = alien.id;\nvar createdAt = alien.createdAt;\nvar updatedAt = alien.updatedAt;\n```\n\nNote that these fields cannot be retrieved via the `.get()` method.\n\n\n### Updating Objects\n\nWhenever you use `.save()` or `Warp Queries` to save/retrieve objects, you can modify the keys of these objects directly using the same `.set()` method. Warp automatically knows that you've updated these fields and prepares the object for updating.\n\nFor example, after the `.save()` method:\n\n```javascript\nvar alien = new Warp.Object('alien');\nalien.set('name', 'Madam Vestra');\nalien.set('type', 4);\n\nalien.save().then(function() {\n    // If this is the 200th alien, change its type, for example\n    if(alien.id \u003e 200)\n        alien.set('type', 5);\n\n    // Update the alien\n    return alien.save();\n    \n})\n.then(function() {\n    // The alien has been successfully updated\n});\n\n```\n\nFor example, after retrieving from `Warp Queries`:\n\n```javascript\nvar alienQuery = new Warp.Query('alien');\nalienQuery.equalTo('id', 5);\n\nalienQuery.first(function(alien) {\n    alien.set('age', 30);\n    return alien.save();\n})\n.then(function() {\n    // The alien has been successfully saved\n});\n\n```\n\nAdditionally, if the key you are trying to update is an `integer` and you want to atomically increase or decrease its value, you can opt to use the `.increment()` method instead.\n\nFor example, if you want to increase the age by 1, you would use the following code:\n\n```javascript\nalien.increment('age', 1);\n```\n\nConversely, if you want to decrease an `integer` key, you would use a negative value:\n\n```javascript\nalien.increment('life_points', -5);\n```\n\n\n### Deleting Objects\n\nIf you want to delete a saved or retrieved object, all you need to do is call the `.destroy()` method of the object:\n\n```javascript\nalien.destroy();\n```\n\nAdditionally, like `.save()`, the `.destroy()` method also returns a promise, which you can chain other processes to:\n\n```javascript\nalien.destroy().then(function() {\n    alert('The alien has been destroyed');\n});\n\n// or\n\nalien.destroy(function() {\n    alert('The alien has been destroyed');\n});\n```\n\n\n### Pointers\n\nIf your objects use [pointers](https://github.com/dividedbyzeroco/warp-server#pointers) for some of its keys, you can directly set them via the `.set()` method.\n\nFor example, if you are creating a `planet` for an `alien` object, you can use the following approach:\n\n```javascript\nvar planet = new Warp.Object('planet');\nplanet.set('name', 'Raxocoricofallipatorius');\n\n// NOTE: Before you can use the `planet` object, you must first save it\nplanet.save(function() {\n    var alien = new Warp.Object('alien');\n    alien.set('name', 'Slitheen');\n    alien.set('planet', planet); // Set the object directly\n    return alien.save();\n})\n.then(function() {\n    // The alien has been successfully saved\n});\n```\n\nIf, for example, you have an existing `planet` and you want to use it for an `alien` object, you can use the following approach:\n\n```javascript\n// Warp.Object.createWithoutData({ID}, '{CLASS_NAME}');\n// For users, Warp.User.createWithoutData({ID});\nvar planet = Warp.Object.createWithoutData(2, 'planet');\nvar alien = new Warp.Object('alien');\nalien.set('name', 'Captain Jack Harkness');\nalien.set('planet', planet); // Set the object directly\n\nalien.save(function() {\n    // The alien has been successfully saved\n});\n```\n\n\n### Files\n\nIf you need to upload [files](https://github.com/dividedbyzeroco/warp-server#files) to the server, you can do so via `Warp Files`.\n\nFor example, if you are creating an `avatar_pic` for an `alien` object, you can use the following approach.\n\nOn your web app, you would have an `input` DOM element to select files:\n\n```html\n\u003cinput type='file' name='avatar_pic' id='avatar-pic'\u003e\n```\n\nThen, in your script, you would add the following code:\n\n```javascript\n// Select the input DOM element\nvar fileInput = document.querySelector('#avatar-pic');\n\n// Check if a file is selected\nif(fileInput.files.length == 0) return 'No file selected';\n\n// Create a new Warp File using the following format: new Warp.File('{DESIRED_FILE_NAME}', '{FILE_DATA}');\n//\n// NOTE:\n// 1. The File name does not need to be unique\n// 2. File extension must be part of the file name\n// 3. You may use `/` slashes for the file name (ideal for blob storage)\n\nvar avatarPic = new Warp.File('avatarPic001.jpg', fileInput.files[0]);\n```\n\nAfter preparing the file, you can now use `.save()` to upload it to the server, and then `.set()` to set the specified file for an object:\n\n```javascript\navatarPic.save().then(function() {\n    var alien = new Warp.Object('alien');\n    alien.set('name', 'Sycorax');\n    alien.set('avatar_pic', avatarPic); // Set the file directly\n\n    // Save the new alien\n    return alien.save();\n})\n.then(function() {\n    // The alien has been successfully saved\n});\n```\n\n\n### Subclasses\n\nUsing the `Warp Object` allows you to create objects on-the-fly without having to worry about additional configurations. If, however, you want to modularize your code into classes, you may opt to use the `.extend()` method in order to create customized subclasses.\n\nFor example, if you want to create a subclass called `Alien` that extends from `Warp.Object`, you can do so using the following code:\n\n```javascript\nvar Alien = Warp.Object.extend('alien');\n```\n\nWhat's useful about subclasses is you can set your own `instance methods` and `static methods` just like in basic Object-oriented Programming:\n\n```javascript\nvar Alien = Warp.Object.extend('alien', {\n    // Instance methods\n    initialize: function() {\n        // NOTE: `.initialize()` is a special method, it is called whenever a new object is created\n    },\n    greet: function() {\n        return 'Hello! My name is ' + this.get('name');\n    },\n    heal: function(lifepoints) {\n        this.increment('life_points', lifepoints);\n    }\n}, {\n    // Static methods\n    respawn: function(lifepoints) {\n        var alien = new this;\n        alien.set('life_points', lifepoints);\n        return alien;\n    }\n})\n```\n\nNow that you've created your subclass, you can now use it in place of `Warp Object`:\n\n```javascript\nvar alien = new Alien();\nalien.set('name', 'The Doctor');\nalien.set('life_points', 800);\nalien.save().then(function() {\n    // Heal the alien\n    alien.heal(200);\n    return alien.save();\n});\n\nvar alien2 = Alien.respawn(1000);\nalien2.set('name', 'The Master');\nalien2.save().then(function() {\n    // Successfully saved the Master\n    var greeting = alien2.greet();\n});\n```\n\nAdditionally, you can extend the subclass even further to create more specific subclasses:\n\n```javascript\nvar Dalek = Alien.extend({\n    setTime: function(time) {\n        this.set('time_period', time);\n    }\n}, {\n    createWarrior: function() {\n        var warrior = new this;\n        warrior.set('role', 'Warrior');\n        return warrior;\n    }\n});\n\nvar dalek = new Dalek({ name: 'Khan' });\ndalek.save();\n```\n\nWhat's important is that for every subclass that you make, you must register them before you initialize Warp:\n\n```javascript\nWarp.Object.registerSubclass(Alien);\nWarp.Object.registerSubclass(Dalek);\nWarp.Object.registerSubclass(Planet);\nWarp.initialize({ apiKey: '12345678abcdefg', baseURL: 'http://my-warp-server.com/api/1' });\n```\n\n## Queries\n\nThere are certain scenarios when you may need to find Objects from a model. In these instances, it would be convenient to use Queries. Queries allow you to find specific Objects based on a set of criteria.\n\nFor example, if you want to query objects from the `alien` model, you would use the following code:\n\n```javascript\n// Prepare query\nvar alienQuery = new Warp.Query('alien');\n\n// Use `.find()` to get all the objects in the `alien` table\nalienQuery.find().then(function(aliens) {\n    // You now have a collection of all the aliens\n});\n\n// Use `.first()` to get the first object in the `alien` table\nalienQuery.first().then(function(alien) {\n    // You now have the first alien object\n});\n```\n\nIf you've created subclasses via the `.extend()` method of the `Warp Object`, you can set the subclass as the parameter in place of the model name. By using this approach, you get to use the instance methods that you initialized for the subclass:\n\n```javascript\nvar alienQuery = new Warp.Query(Alien);\n\nalienQuery.find(function(aliens) {\n    aliens.each(function(alien) {\n        var greeting = alien.greet();\n        console.log(greeting);\n        return;\n    });\n});\n```\n\n### Constraints\n\nConstraints help filter the results of a specific query. In order to pass constraints for a Query, use any of the following constraints you wish to apply:\n\n```javascript\n// Prepare query\nvar alienQuery = new Warp.Query('alien');\n\n// Find an exact match for the specified key\nalienQuery.equalTo('name', 'The Doctor');\nalienQuery.notEqualTo('name', 'The Master');\n\n// If the key is ordinal (i.e. a string, a number or a date), you can use the following constraints\nalienQuery.lessThan('age', 21);\nalienQuery.lessThanOrEqualTo('name', 'Weeping Angels');\nalienQuery.greaterThanOrEqualTo('life_points', 500);\nalienQuery.greaterThan('created_at', '2016-08-15 17:30:00+00:00');\n\n// If you need to check if a field is null or not null\nalienQuery.exists('type');\nalienQuery.doesNotExist('type');\n\n// If you need to find if a given key belongs in a list, you can use the following constraints\nalienQuery.containedIn('role', ['Doctor', 'Warrior']);\nalienQuery.containedInOrDoesNotExist('role', ['Doctor', 'Warrior']);\nalienQuery.notContainedIn('age', [18, 20]);\n\n// If you need to search a string for a substring\nalienQuery.startsWith('name', 'The');\nalienQuery.endsWith('name', 'Master');\nalienQuery.contains('name', 'M');\n\n// If you need to search multiple keys for a substring\nalienQuery.contains(['name', 'username', 'email'], 'M');\n\n// If you need to search if a value matches several substrings\nalienQuery.containsEither('name', ['M','The','Master']);\n```\n\nNOTE: Queries return a special kind of list called Warp Collections, which you can filter, sort or manipulate. For more info, see the section on [Collections](#collections).\n\n\n### Subqueries\n\nThe constraints above are usually enough for filtering queries; however, if the request calls for a more complex approach, you may nest queries within other queries.\n\nFor example, if you want to retrieve all the aliens who are residents of friendly planets, you may use the following code:\n\n```javascript\nvar friendlyPlanetsQuery = new Warp.Query('planet');\nfriendlyPlanetsQuery.equalTo('type', 'friendly');\n\n// Use the following format\n// .foundIn({KEY IN ALIEN}, {KEY IN PLANET}, {SUBQUERY});\nvar alienQuery = new Warp.Query('alien');\nalienQuery.foundIn('planet_id', 'id', friendlyPlanetsQuery);\n\nalienQuery.find().then(function(friendlyAliens) {\n    // You now have a collection of friendly aliens\n});\n```\n\nIf you want to see if a value exists in either of multiple queries, you can use `.foundInEither()`:\n\n```javascript\nvar friendlyPlanetsQuery = new Warp.Query('planet');\nvar goodPlanetsQuery = new Warp.Query('planet');\nfriendlyPlanetsQuery.equalTo('type', 'friendly');\ngoodPlanetsQuery.equalTo('type', 'good');\n\n// Use the following format\n// .foundInEither({KEY IN ALIEN}, [ {KEY IN PLANET : SUBQUERY}, ... ]);\nvar alienQuery = new Warp.Query('alien');\nalienQuery.foundInEither('planet_id', [{ 'id': friendlyPlanetsQuery }, { 'id': goodPlanetsQuery }]);\n\nalienQuery.find().then(function(friendlyAliens) {\n    // You now have a collection of friendly and good aliens\n});\n```\n\nIf you want to see if a value exists in all of the given queries, you can use `.foundInAll()`:\n\n```javascript\nvar friendlyPlanetsQuery = new Warp.Query('planet');\nvar goodPlanetsQuery = new Warp.Query('planet');\nfriendlyPlanetsQuery.equalTo('type', 'friendly');\ngoodPlanetsQuery.equalTo('type', 'good');\n\n// Use the following format\n// .foundInEither({KEY IN ALIEN}, [ {KEY IN PLANET : SUBQUERY}, ... ]);\nvar alienQuery = new Warp.Query('alien');\nalienQuery.foundInAll('planet_id', [{ 'id': friendlyPlanetsQuery }, { 'id': goodPlanetsQuery }]);\n\nalienQuery.find().then(function(friendlyAliens) {\n    // You now have a collection of friendly and good aliens\n});\n```\n\nConversely, you can use `.notFoundIn()`, and `.notFoundInEither()` to retrieve objects whose key is not found in the given subqueries.\n\n### Limit\n\nBy default, Warp limits results to the top 100 objects that satisfy the query criteria. In order to increase the limit, you can specify the desired value via the `.limit()` method. Also, in order to implement pagination for the results, you can combine the `.limit()` with the `.skip()` methods. The `.skip()` method indicates how many items are to be skipped when executing the query. In terms of scalability, it is advisable to limit results to 1000 and use skip to determine pagination.\n\nFor example:\n\n```javascript\nalienQuery.limit(1000); // Top 1000 results\nalienQuery.skip(1000); // Skip the first 1000 results\n```\n\nNOTE: It is recommended that you use the sorting methods in order to retrieve more predictable results. For more info, see the section below.\n\n\n### Sorting\n\nSorting determines the order by which the results are returned. They are also crucial when using the limit and skip parameters. To sort the query, use the following methods:\n\n```javascript\nalienQuery.sortBy('age'); // Sorts the query by age, in ascending order\nalienQuery.sortByDescending(['created_at', 'life_points']); // You can also use an array to sort by multiple keys\n```\n\n\n### Including Pointer Keys\n\nIn order to include keys that belong to a pointer, we can use the `.include()` method.\n\n```javascript\nalienQuery.include('planet.name');\nalienQuery.include('planet.color');\n```\n\nThe above query will return aliens with their respective planets as pointers:\n\n```javascript\nalienQuery.find().then(function(aliens) {\n    aliens.each(function(alien) {\n        // NOTE: alien.get('planet') returns a Warp Object, which means you can also use .get(), id, createdAt, and updatedAt\n        var greeting = 'I am ' + alien.get('name') + ' and I come from the Planet ' + alien.get('planet').get('name');\n\n        console.log(greeting);\n        return;\n    });\n});\n```\n\n## Collections\n\nWhen using queries, the results returned by `.find()` will be a collection of Warp Objects. Collections are a special list for Warp that allows you to filter, sort and manipulate list items by using a set of in-built methods.\n\n\n### Counting Collections\n\nTo count the results, use the following methods:\n\n```javascript\nvar alienQuery = new Warp.Query('alien');\n\nalienQuery.find().then(function(aliens) {\n    // In this case, `aliens` is a collection\n    var totalAliens = aliens.count();\n});\n```\n\n\n### Filtering Collections\n\nTo filter the results and return a new collection based on these filters, use the following methods:\n\n```javascript\nvar alienQuery = new Warp.Query('alien');\n\nalienQuery.find().then(function(aliens) {\n    // Returns the first Warp Object\n    var firstAlien = aliens.first();    \n    \n    // Returns a collection of Warp Objects that match the given object\n    var redDaleksOnly = aliens.match({ type: 'Daleks', color: 'red' });\n\n    // Returns a collection of Warp Objects that return true for the given function\n    var oldAliensOnly = aliens.where(function(alien) {\n        return alien.get('age') \u003e 100;\n    });\n});\n```\n\n\n### Sorting Collections\n\nTo sort the results and return a new collection, use the following methods:\n\n```javascript\nvar alienQuery = new Warp.Query('alien');\n\nalienQuery.find().then(function(aliens) {\n    // Returns a new collection sorted in ascending order\n    var aliensSortedByLifePoints = aliens.sortBy('life_points');\n\n    // Returns a new collection sorted in descending order\n    var aliensSortedByCreatedAt = aliens.sortByDescending('created_at');\n    \n});\n```\n\n\n### Manipulating Collections\n\nTo manipulate the results, use the following methods:\n\n```javascript\nvar alienQuery = new Warp.Query('alien');\n\nalienQuery.find().then(function(aliens) {\n    // Looks through each Warp Object and applies the given function\n    // NOTE: You can return Promises inside the function and it will wait for each promise to finish before continuing to the next item\n    aliens.each(function(alien) {\n        return alien.destroy();\n    });\n\n    // Returns an array of whatever the given function returns\n    var names = aliens.map(function(alien) {\n        return alien.get('name');\n    });\n\n    // As an added bonus, you can use ES2015 lambda functions inside these methods\n    aliens.each(alien =\u003e alien.destroy());\n\n    var names = aliens.map(alien =\u003e alien.get('name'));\n    \n});\n```\n\n\n### Converting Collections\n\nOften times, you may opt to use regular array lists to handle Warp Objects. In these cases, you can convert Warp Collections using the following methods:\n\n```javascript\nvar alienQuery = new Warp.Query('alien');\n\nalienQuery.find().then(function(aliens) {\n    // Returns a list of Warp Objects\n    var alienArray = aliens.toList();\n\n    // Returns a list of regular JavaScript Objects similar to the REST API\n    // For more info, visit http://github.com/dividedbyzeroco/warp-server/blob/master/rest.md\n    var alienJSON = aliens.toJSON();\n});\n```\n\n\n### Chaining Methods\n\nSince Warp Collections return new Collections after every method, you can chain several methods together, as needed:\n\n```javascript\nvar alienQuery = new Warp.Query('alien');\n\nalienQuery.find().then(function(aliens) {\n    // Find red aliens, sort them by life points and then return their name\n    var redAliens = aliens.where({ color: 'red' })\n                    .sortBy('life_points')\n                    .map(alien =\u003e alien.get('name'));\n});\n```\n\n## Users\n\nUser accounts are often an essential part of an application. In Warp, these are represented by Warp Users. Warp Users are extended from the Warp Object, which means you can use the same methods found in Warp Objects; however, Warp Users have additional methods specifically tailored for user account management.\n\n\n### Getting Special User Keys\n\nAside from id, createdAt and updatedAt, Warp User also has the following get methods:\n\n```javascript\nvar userQuery = new Warp.Query(Warp.User);\nuserQuery.equalTo('id', 5).first().then(user =\u003e {\n    var id = user.id;\n    var createdAt = user.createdAt;\n    var updatedAt = user.updatedAt;\n    var username = user.getUsername();\n    var email = user.getEmail();\n});\n```\n\nNote that for Warp Query, instead of specifiying 'user' as the string, we can simply place Warp.User as the parameter.\n\n\n### Logging In\n\nIn order to log in to a user account, you would use the `.logIn()` method:\n\n```javascript\nWarp.User.logIn('username', 'password', function(user) {\n    // Successfully logged in\n}, function(error) {\n    // There was an error\n});\n\n// or\n\nWarp.User.logIn('username', 'password')\n.then(function(user) {\n    // Successfully logged in\n})\n.catch(function(error) {\n    // There was an error\n});\n```\n\nNote that you cannot use `.logIn()` when using the Warp JS SDK for server-side development.\n\n### Fetching Current User\n\nTo get the currently logged in user, you would use the `.current()` method:\n\n```javascript\nvar current = Warp.User.current();\n```\n\n\n### Signing Up\n\nTo register a new user account, you would use the `.signUp()` method:\n\n```javascript\nvar user = new Warp.User();\nuser.setUsername('Luke Smith');\nuser.setPassword('k9_and_sara');\n\nuser.signUp(function() {\n    // Signed up; `.current()` returns the registered user\n    var current = Warp.User.current();\n}, function(error) {\n    // There was an error\n});\n\n// or\n\nuser.signUp()\n.then(function() {\n    // Signed up; `.current()` returns the registered user\n    var current = Warp.User.current();\n})\n.catch(function() {\n    // There was an error\n});\n```\n\nNote that you cannot use `.save()` to create a user. You can only use `.save()` to update a user which has been registered or logged in.\nAlso, note that you cannot use `.signUp()` when using the Warp JS SDK for server-side development.\n\n\n### Logging Out\n\nTo log out of a user account, you would use the `.logOut()` method:\n\n```javascript\nuser.logOut(function() {\n    // Logged out; `.current()` now returns null\n    var current = Warp.User.current();\n}, function(error) {\n    // There was an error\n});\n\n// or\n\nuser.logOut()\n.then(function() {\n    // Logged out; `.current()` now returns null\n    var current = Warp.User.current();\n})\n.catch(function(error) {\n    // There was an error\n});\n```\n\n## Functions\n\nTo run Warp [Functions](http://github.com/dividedbyzeroco/warp-server#functions) from the API, you may use Warp Functions:\n\n```javascript\n// Warp.Function.run({FUNCTION_NAME}, {PARAMETERS})\n\nWarp.Function.run('get-votes', { from: '2016-08-14', to: '2016-08-15' }, function(result) {\n    // `result` contains a JSON Object of the results from the API\n}, function(error) {\n    // There was an error\n});\n\n// or\n\nWarp.Function.run('get-votes', { from: '2016-08-14', to: '2016-08-15' })\n.then(function(result) {\n    // `result` contains a JSON Object of the results from the API\n})\n.catch(function(error) {\n    // There was an error\n});\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdividedbyzeroco%2Fwarp-sdk-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdividedbyzeroco%2Fwarp-sdk-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdividedbyzeroco%2Fwarp-sdk-js/lists"}