{"id":29020350,"url":"https://github.com/appbaseio/appbase.js-deprecate","last_synced_at":"2025-06-26T01:05:27.476Z","repository":{"id":30397721,"uuid":"33950472","full_name":"appbaseio/appbase.js-deprecate","owner":"appbaseio","description":"JavaScript Wrapper for Appbase Rest API","archived":false,"fork":false,"pushed_at":"2015-05-27T19:26:30.000Z","size":424,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-06-19T03:06:40.613Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/appbaseio.png","metadata":{"files":{"readme":"README.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}},"created_at":"2015-04-14T18:49:29.000Z","updated_at":"2016-12-01T01:59:05.000Z","dependencies_parsed_at":"2022-09-19T05:51:20.765Z","dependency_job_id":null,"html_url":"https://github.com/appbaseio/appbase.js-deprecate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/appbaseio/appbase.js-deprecate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appbaseio%2Fappbase.js-deprecate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appbaseio%2Fappbase.js-deprecate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appbaseio%2Fappbase.js-deprecate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appbaseio%2Fappbase.js-deprecate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/appbaseio","download_url":"https://codeload.github.com/appbaseio/appbase.js-deprecate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appbaseio%2Fappbase.js-deprecate/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261978910,"owners_count":23239417,"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":"2025-06-26T01:05:26.257Z","updated_at":"2025-06-26T01:05:27.462Z","avatar_url":"https://github.com/appbaseio.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# appbase.js\nJavaScript Wrapper for Appbase Rest API\n\n\n1. Appbase Global Object\n-----------\n\nThe Appbase object is responsible for instantiating Apps.\n\n\n----------\n### Methods  \n**Appbase.app(appname, secret)**  \nUsed to create a new instance of a App  \nParameters:\n ```\n - appname: String - The name of the app on your appbase dashboard\n - secret: String - The secret of the app\n ```\n#### Example\n```javascript\n    var restTestApp = Appbase.app(\"rest_test\", \"193dc4d2440146082ea734f36f4f2638\");\n```\n \n----------\n\n2. App Class\n-----------\nThe App class has utility methods to manage the App's collections.\n\n----------\n###Methods  \n **App.search(query)**  \nThis method searches the App's collections with the given query.  \n[View in the REST API Docs](http://docs.appbase.io/#/v3.0/rest/api-reference#api-reference-global-search-collections)    \nParameters:  \n ```\n - query: Object - A JS Object to query the collections.\n ```\n Example\n ```javascript\n    AppTest.search({\n        match_all : {}\n    })\n    .then(function(response){\n       response.hits.hits.forEach(console.log.bind(console)); // hits.hits - Contains all matched objects, limited by the query or by default 10\n       console.log(response.hits.total); // hits.total - Total number of objects matched\n    });\n ```\n \n  **AppTest.listCollections()**  \nThis method retrieves all the collections of the app.  \n[View in the REST API Docs](http://docs.appbase.io/#/v3.0/rest/api-reference#api-reference-global-list-collections)  \n\n```javascript\n    AppTest.listCollections() // Returns a promise\n    .then(function(collections) {\n        collections.forEach(function(collection) { // The collections variable is a array of Collection\n            console.log(collection.name);\n        });\n    });\n ```\n\n**AppTest.serverTime()**  \nReturns the server timestamp in milliseconds.  \n[View in the REST API Docs](http://docs.appbase.io/#/v3.0/rest/api-reference#api-reference-global-server-time)  \n\n```javascript\n    AppTest.serverTime() // Returns a promise\n    .then(function(time) {\n        console.log(time); // 1430941365939\n    });\n```\n\n**AppTest.collection(name)**  \nReturns a Collection object for the provided name  \n\nParameters:  \n ```\n - name: String - The name of the collection, should already exists in your dashboard.  \n ```\n \n```javascript\nvar userCollection = AppTest.collection('user');\n```\n\n3. Collection Class\n-----------\nProvides an interface to the Appbase's REST endpoints to manage your collections.\n[View in the REST API Docs](http://docs.appbase.io/#/v3.0/rest/api-reference)\n\n----------\n## Properties\n```\nname String - The name of the collection\n```\n\n## Methods\n\n**collection.search(query)**\nSearches the collection's documents with the provided query.\n[View in the REST API Docs](http://docs.appbase.io/#/v3.0/rest/api-reference#api-reference-collection-search-documents-by-propertyies)    \nParameters:  \n ```\n - query: Object - A JS Object to query the collection.\n ```\n\n```javascript\n    userCollection.search({ // Returns a promise\n        filter : {\n            term : {\n                foo : 'bar'\n            }\n        }\n    }).then(function(response) {\n        console.log(response.hits.hits)\n    });\n```\n\n**collection.insert(entry)**\nCreate a new document in the collection\n[View in the REST API Docs](http://docs.appbase.io/#/v3.0/rest/api-reference#api-reference-document-properties-create-update-document-properties)\n\nParameters:  \n ```\n - entry: Object - A JS Object to be added to the collection.\n ```\n\n```javascript\n    userCollection.insert({ // Returns a promise\n        foo : 'bar',\n        name : 'aName'\n    }).then(function(response) {\n        console.log(response)\n        /*\n            {\n                \"foo\": \"bar\",\n                \"name\": \"aName\",\n                \"_id\": \"c12c7649-53e3-44bf-bbe8-f23769885eb0\",\n                \"_collection\": \"calls\",\n                \"_timestamp\": 1430943009686\n            }\n        */\n    });\n```\n\n**collection.set(key, entry)**\nCreate or update a new document in the collection, with the provided key as the id of that object.\n[View in the REST API Docs](http://docs.appbase.io/#/v3.0/rest/api-reference#api-reference-document-properties-create-update-document-properties)\n\nParameters:  \n ```\n - key: String - A unique key.\n - entry: Object - A JS Object to be added to the collection.\n ```\n\n```javascript\n    userCollection.set('12345', { // Returns a promise\n        foo : 'bar',\n        name : 'aName'\n    }).then(function(response) {\n        console.log(response)\n        /*\n            {\n                \"foo\": \"bar\",\n                \"name\": \"aName\",\n                \"_id\": \"12345\",\n                \"_collection\": \"calls\",\n                \"_timestamp\": 1430943009686\n            }\n        */\n    });\n```\n\n**collection.unset(key, properties)**\nDelete specific (or all) data properties of a document.\n[View in the REST API Docs](http://docs.appbase.io/#/v3.0/rest/api-reference#api-reference-document-properties-delete-document-properties)\n\nParameters:  \n ```\n - key: String - Document's unique key.\n - entry: Array\u003cString\u003e - A array of Strings with the name of the properties tobe removed.\n ```\n\n```javascript\n    userCollection.unset('12345', ['bar']).then(function(response) { // Returns a promise\n        console.log(response)\n        /*\n            {\n                \"foo\": \"\", // Notice that foo is now empty\n                \"name\": \"aName\",\n                \"_id\": \"12345\",\n                \"_collection\": \"calls\",\n                \"_timestamp\": 1430943009686\n            }\n        */\n    });\n```\n\n**collection.get(key)**\nRead the existing document properties.\n[View in the REST API Docs](http://docs.appbase.io/#/v3.0/rest/api-reference#api-reference-document-properties-read-document-properties)\n\nParameters:  \n ```\n - key: String - Document's unique key.\n ```\n\n```javascript\n    userCollection.get('12345').then(function(response) { // Returns a promise\n        console.log(response)\n        /*\n            {\n                \"foo\": \"\",\n                \"name\": \"aName\",\n                \"_id\": \"12345\",\n                \"_collection\": \"calls\",\n                \"_timestamp\": 1430943009686\n            }\n        */\n    });\n```\n\n**collection.getAll([filters])**\nList the documents in the collection. Returns an array of documents in the given collection.\n[View in the REST API Docs](http://docs.appbase.io/#/v3.0/rest/api-reference#api-reference-collection-list-all-documents)\n\nParameters:  \n ```\n - filters: Object - Optional Object to paginate the collection's documents, you may specify limit and skip.\n ```\n\n```javascript\n    userCollection.getAll({ // Returns a promise\n        limit : 3, // Get 3 objects\n        skip : 2   // Start by the second\n    }).then(function(response) {\n        console.log(response)\n        /*\n            [\n                {\n                    \"foo\": \"bar\",\n                    \"_collection\": \"user\",\n                    \"_id\": \"4fcaaab1636e48ca988ffe075ec820b5\",\n                    \"_timestamp\": 1427918110979\n                },\n                {\n                    \"foo\": \"bar\",\n                    \"_collection\": \"user\",\n                    \"_id\": \"77623095cf284c4c8768a0393e40aacf\",\n                    \"_timestamp\": 1427920330170\n                },\n                {\n                    \"name\": \"sid\",\n                    \"name1\": \"sagar\",\n                    \"_collection\": \"user\",\n                    \"_id\": \"sid\",\n                    \"_timestamp\": 1428103822887\n                }\n            ]\n        */\n    });\n```\n\n**collection.on(key, callback[, errorCallback])**\nListen to changes on the Document with the provided key.\n\n\nParameters:  \n ```\n - key: String - Document's unique key.\n - callback: Function - A function to be called whenever a change occurs to the Document.\n - errorCallback: Function - A function to be called whenever a error occurs in the call, may be called more than once.\n ```\n\n```javascript\n    userCollection.on('12345', function(response) {\n        console.log(response); // Will log the object every time it has a change\n    });\n```\n\n\n**collection.onDocuments(callback[, errorCallback])**\nListen to the creation or changes on any Document in the collection.\n\nParameters:  \n ```\n - callback: Function - A function to be called whenever a new Document is created or a change occurs to a Document.\n - errorCallback: Function - A function to be called whenever a error occurs in the call, may be called more than once.\n ```\n\n```javascript\n    userCollection.onDocuments(function(response) {\n        console.log(response); // Will log the object every time it has a new or changed Document\n    });\n```\n\n**collection.onRef(key, callback[, errorCallback])**\nListen to the creation or changes of References on the Document that has the provided key.\n\nParameters:  \n ```\n - key: String - Document's unique key.\n - callback: Function - A function to be called whenever a new Reference is created or a changes in a Document.\n - errorCallback: Function - A function to be called whenever a error occurs in the call, may be called more than once.\n ```\n\n```javascript\n    userCollection.onRef('12345', function(response) {\n        console.log(response); // Will log the object every time it has a new or changed Ref in the Document\n        /*\n        {\n            \"friend\": {\n                \"_timestamp\": 1431040446952,\n                \"_json\": {\n                    \"_id\": \"sagar\",\n                    \"name1\": \"sagar\",\n                    \"name\": \"1123\",\n                    \"_collection\": \"user\",\n                    \"_timestamp\": 1429562388858\n                }\n            }\n        } */\n    });\n```\n\n\n**collection.setRef(key, ref, path[, priority])**\nListen to the creation or changes of References on the Document that has the provided key.\n[View in the REST API Docs](http://docs.appbase.io/#/v3.0/rest/api-reference#api-reference-document-references-create-update-document-references)\n\nParameters:  \n ```\n - key: String - Document's unique key.\n - callback: Function - A function to be called whenever a new Reference is created or a changes in a Document.\n - errorCallback: Function - A function to be called whenever a error occurs in the call, may be called more than once.\n ```\n\n```javascript\n    userCollection.setRef('12345', 'friend', 'user/sagar').then(function(response) { // Returns a promise\n        console.log(response);\n        /*\n        {\n            \"friend\": {\n                \"timestamp\": 1431040446952\n            }\n        }\n        */\n    });\n```\n\n**collection.getRefs(key[, filters])**\nGet all the References of the Document with the provided key.\n[View in the REST API Docs](http://docs.appbase.io/#/v3.0/rest/api-reference#api-reference-document-references-read-references)\n\nParameters:  \n ```\n - key: String - Document's unique key.\n - filters: Object - Optional Object to paginate the documents's References, you may specify limit and skip.\n ```\n\n```javascript\n    userCollection.getRefs('12345', { // Returns a promise\n        limit : 3, // Get 3 objects\n        skip : 2   // Start by the second\n    }).then(function(response) {\n        console.log(response);\n        /*\n        [\n            {\n                \"friend\": {\n                    \"_timestamp\": 1431040446952,\n                    \"_json\": {\n                        \"_id\": \"sagar\",\n                        \"name1\": \"sagar\",\n                        \"name\": \"1123\",\n                        \"_collection\": \"user\",\n                        \"_timestamp\": 1429562388858\n                    }\n                }\n            }\n        ]\n        */\n    });\n```\n\n**collection.unsetRefs(key, references)**\nRemoves the provided References from the Document with the provided key.\n[View in the REST API Docs](http://docs.appbase.io/#/v3.0/rest/api-reference#api-reference-document-references-delete-references)\n\nParameters:  \n ```\n - key: String - Document's unique key.\n - references: Array\u003cString\u003e - Names of References to be removed from the object.\n ```\n\n```javascript\n    userCollection.unsetRefs('12345', ['friend']).then(function(response) { // Returns a promise\n        console.log(response);\n    });\n```\n\n\n**collection.delete(key)**\nRemoves the Document with the provided key from the collection.\n\nParameters:  \n ```\n - key: String - Document's unique key.\n ```\n\n```javascript\n    userCollection.delete('12345').then(function(response) { // Returns a promise\n        console.log(response);\n        /*\n        {\n            \"_collection\": \"user\",\n            \"_id\": \"4fcaaab1636e48ca988ffe075ec820b5\",\n            \"_timestamp\": 1431042743261,\n            \"_deleted\": true\n        }\n        */\n    });\n```\n\n\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappbaseio%2Fappbase.js-deprecate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappbaseio%2Fappbase.js-deprecate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappbaseio%2Fappbase.js-deprecate/lists"}