UNPKG

@harishreddym/baqend

Version:

Baqend JavaScript SDK

140 lines 369 kB
{ "docs": [ { "location": "/gettingstarted/", "text": "Quickstart\n\n\nFollow this 5 minute quickstart, to setup a new web project with Baqend. We will build a simple message wall.\n\n\n\n\n\n\nCreate a Baqend Account\n\n\nTo build a new application, first \ncreate a Baqend account\n. Type in a name for your new application and a dedicated server instance will be deployed and hooked up to our global caching infrastructure (typically in 20 seconds).\n\n\n\n\n\nDownload Boilerplate Web Project\n\n\nWe'll start with \nthis empty HTML5 Bootstrap project\n (or \nconfigure a custom one\n). Unzip it, to get the following folder structure:\n\n\n\nindex.html\n <-- here we will put some HTML to accept input data\njs\n \nmain.js\n <-- your application logic hooked up to Baqend\n vendor <-- JavaScript libraries\ncss\n main.css <-- our style\n bootstrap.css <-- \nBootstrap\n style\nimg, fonts <-- assets\n\n\nIn a few steps your app will look like this:\n\n\n\n\n\n\n\n\nInstall Baqend\n\n\nTo install Baqend to the application (alreay included in the zip you downloaded), just add the CDN-hosted Baqend SDK \nat the end of the \n<body>\n section of the index.html using your favourite IDE (e.g. \nWebStorm\n) \nor text editor (e.g. \nSublime\n):\n\n\n<script src=\"https://www.baqend.com/js-sdk/latest/baqend.min.js\"></script>\n\n\n\n\nOther installation methods (e.g. npm) are explained \non Github\n.\n\n\n\n\n\nConnect to the Cloud\n\n\nIn the \nmain.js\n, add the following lines to connect to Baqend Cloud:\n\n\nDB.connect(\"<your-app-name>\", function() {\n showMessages();\n});\n\n\n\n\nThe callback is invoked when the connection is established. We will use that to display the message wall in \nshowMessages\n, but first we need some data.\n\n\n\n\n\nDefine the Data Model\n\n\nIn the \ndashboard\n enter your App and create a new table named \nMessage\n in the \nData\n menu on the left. In the schema tab that is now open, add three attributes:\n\n\n\nAttribute Name\nType\n\n\nname\nString\n\n\nmessage\nString\n\n\ndate\nDateTime\n\n\n\nNow go to the \nData\n tab and click \nAdd\n to insert a dummy message to the database.\n\n\nTo learn more about data modeling in Baqend, see the \nSchema and Types documentation\n.\n\n\n\n\n\nSave Data\n\n\nNow, let's enhance the \nindex.html\n with an input for name and message as well as post button. Replace all the code starting before \n<div class=\"jumbotron\">\n just until the \n<hr>\n with this:\n\n\n<div class=\"jumbotron\">\n <form onsubmit=\"leaveMessage(this.name.value, this.message.value);\n this.reset(); return false;\" class=\"form-inline text-center container\">\n <input class=\"form-control\" name=\"name\" placeholder=\"Name\">\n <input class=\"form-control\" name=\"message\" placeholder=\"Message\">\n <button type=\"submit\" class=\"btn btn-primary\">Leave Message</button>\n</form>\n</div>\n<div class=\"container\"><div class=\"row\" id=\"messages\"></div>\n\n\n\n\nSo when hitting enter or the button, our \nleaveMessage\n function is called. Let's add it to \nmain.js\n:\n\n\nfunction leaveMessage(name, message) {\n //Create new message object\n var msg = new DB.Message();\n //Set the properties\n msg.name = name;\n msg.message = message;\n msg.date = new Date();\n //Insert it to the database\n msg.insert().then(showMessages);\n}\n\n\n\n\nSo now we insert a new message, whenever the HTML form is submitted.\n\n\nSee the \nC\nreate \nR\nead \nU\npdate \nD\nelete documentation\n to learn more about saving and loading data.\n\n\n\n\n\nQuery Data\n\n\nNow, let's display the stored data. To show the 30 newest messages, ordered by time stamp perform a simple query:\n\n\nfunction showMessages() {\n DB.Message.find()\n .descending(\"date\")\n .limit(30)\n .resultList()\n .then(function(result) {\n var html = \"\";\n result.forEach(function(msg) {\n html += '<div class=\"col-md-4\"><h2>';\n html += msg.name + '</h2><p>' + msg.message + '</p></div>';\n });\n document.getElementById(\"messages\").innerHTML = html;\n });\n}\n\n\n\n\nAt this point the application is fully working. Just open the \nindex.html\n in the browser to use your app. If something is not working, press \nF12\n to see any error messages.\n\n\nQueries allow you do complex filtering and sorting, see the \nQuery Docs\n. All data loaded from Baqend Cloud is served with low latency from a global CDN.\n\n\n\n\n\nProtect Your Data\n\n\nBy default, public access to the \nMessage\n table is allowed. Let's restrict that to only allow \ninserts\n, \nreads\n and \nqueries\n but disallow any \nupdates\n and \ndeletes\n. Go to the \nACL\n (Access Control Lists) tab in the dashboard and revoke delete and update rights from the Public role.\n\n\nAccess rights can be granted and denied both at table level and at object level. This is explained in detail in the \nUser, Roles and Permissions documentation\n.\n\n\nBaqend has full SSL support. If you want the Baqend connection to be SSL-encrypted by default, add \ntrue\n as the second parameter of the \nDB.connect\n call.\n\n\n\n\n\nAdd User Registration and Login\n\n\nIf you would like your users to login into your application, that's easy. Your app has a predefined \nUser\n table and the Baqend SDK comes with built-in ways to register and log in users:\n\n\nDB.User.register('john.doe@example.com', 'pwd').then(function() {\n //Now we are logged in\n console.log(DB.User.me.username); //'john.doe@example.com'\n});\n//When coming back, just log in:\nDB.User.login('john.doe@example.com', 'pwd').then(...)\n\n\n\n\nYou can enable and customize email verification in the settings page of the dashboard. To support OAuth logins (e.g. \"Login with Facebook\"), setup OAuth as \ndescribed in the User docs\n, then you can simply call \nDB.User.loginWithFacebook\n.\n\n\n\n\n\n\nInstall the Baqend CLI and Deploy\n\n\nInstall the \nBaqend CLI\n globally with (\nnode.js and npm\n is required):\n\n\n$ npm install -g baqend\n\n\n\n\nDeploy your first app version by typing: \n\n\n$ baqend deploy --file-dir . <your-app-name>\n\n\n\n\nView it online by visiting your app domain \n<your-app-name>.app.baqend.com\n.\n\n\n\n\n\n\nStart Building\n\n\nYou can use the app you just created as a baseline for a real app. To explore Baqend's other features:\n\n\n \nTake the \nInteractive Tutorial\n\n \nRead the \nDeveloper Guide\n, to learn about server-side code & validations, push notifications, logging, etc.\n\n \nRead the \nJavaScript API Docs\n\n \nPlay with the Interative REST API: \nOpen Your App\n and go to \nAPI Explorer\n\n \nIf you're starting from scratch, have a look at frontend bootstraping tools: \nInitializr\n (used here), \nHTML5 Boilerplate\n, \nBootstrap\n, \nYeoman\n and popular frontend frameworks: \nIonic\n, \nAngularJS\n, \nReact\n, \nEmber\n\n\n\n\n\n\n\n\n\n.getting-started-list {\n list-style: none;\n counter-reset: cnt;\n margin-left: 0;\n margin-top: 40px;\n}\n\n.getting-started-list ul li{\n padding: 10px 0;\n}\n\n.getting-started-list h3 {\n margin-top: -110px;\n position: relative;\n z-index: -1;\n}\n\n.getting-started-list>li {\n position: relative;\n border-left: 2px solid #1967CC;\n padding: 0 0 60px 50px;\n /* disable collapsed margin */\n display: inline-block;\n width: 100%;\n}\n\n.getting-started-list>li:last-child {\n border: none;\n}\n\n.getting-started-list>li:before {\n counter-increment: cnt;\n content: counter(cnt);\n position: absolute;\n left: -18px;\n border-radius: 50%;\n background-color: #FFFFFF;\n display: block;\n width: 35px;\n height: 35px;\n line-height: 31px;\n color: #1967CC;\n border: 2px solid #1967CC;\n text-align: center;\n font-size: 21px;\n}", "title": "Quickstart" }, { "location": "/gettingstarted/#quickstart", "text": "Follow this 5 minute quickstart, to setup a new web project with Baqend. We will build a simple message wall.", "title": "Quickstart" }, { "location": "/gettingstarted/#create-a-baqend-account", "text": "To build a new application, first create a Baqend account . Type in a name for your new application and a dedicated server instance will be deployed and hooked up to our global caching infrastructure (typically in 20 seconds).", "title": "Create a Baqend Account" }, { "location": "/gettingstarted/#download-boilerplate-web-project", "text": "We'll start with this empty HTML5 Bootstrap project (or configure a custom one ). Unzip it, to get the following folder structure: index.html <-- here we will put some HTML to accept input data\njs\n main.js <-- your application logic hooked up to Baqend\n vendor <-- JavaScript libraries\ncss\n main.css <-- our style\n bootstrap.css <-- Bootstrap style\nimg, fonts <-- assets \nIn a few steps your app will look like this:", "title": "Download Boilerplate Web Project" }, { "location": "/gettingstarted/#install-baqend", "text": "To install Baqend to the application (alreay included in the zip you downloaded), just add the CDN-hosted Baqend SDK \nat the end of the <body> section of the index.html using your favourite IDE (e.g. WebStorm ) \nor text editor (e.g. Sublime ): <script src=\"https://www.baqend.com/js-sdk/latest/baqend.min.js\"></script> Other installation methods (e.g. npm) are explained on Github .", "title": "Install Baqend" }, { "location": "/gettingstarted/#connect-to-the-cloud", "text": "In the main.js , add the following lines to connect to Baqend Cloud: DB.connect(\"<your-app-name>\", function() {\n showMessages();\n}); The callback is invoked when the connection is established. We will use that to display the message wall in showMessages , but first we need some data.", "title": "Connect to the Cloud" }, { "location": "/gettingstarted/#define-the-data-model", "text": "In the dashboard enter your App and create a new table named Message in the Data menu on the left. In the schema tab that is now open, add three attributes: Attribute Name Type name String message String date DateTime \nNow go to the Data tab and click Add to insert a dummy message to the database. To learn more about data modeling in Baqend, see the Schema and Types documentation .", "title": "Define the Data Model" }, { "location": "/gettingstarted/#save-data", "text": "Now, let's enhance the index.html with an input for name and message as well as post button. Replace all the code starting before <div class=\"jumbotron\"> just until the <hr> with this: <div class=\"jumbotron\">\n <form onsubmit=\"leaveMessage(this.name.value, this.message.value);\n this.reset(); return false;\" class=\"form-inline text-center container\">\n <input class=\"form-control\" name=\"name\" placeholder=\"Name\">\n <input class=\"form-control\" name=\"message\" placeholder=\"Message\">\n <button type=\"submit\" class=\"btn btn-primary\">Leave Message</button>\n</form>\n</div>\n<div class=\"container\"><div class=\"row\" id=\"messages\"></div> So when hitting enter or the button, our leaveMessage function is called. Let's add it to main.js : function leaveMessage(name, message) {\n //Create new message object\n var msg = new DB.Message();\n //Set the properties\n msg.name = name;\n msg.message = message;\n msg.date = new Date();\n //Insert it to the database\n msg.insert().then(showMessages);\n} So now we insert a new message, whenever the HTML form is submitted. See the C reate R ead U pdate D elete documentation to learn more about saving and loading data.", "title": "Save Data" }, { "location": "/gettingstarted/#query-data", "text": "Now, let's display the stored data. To show the 30 newest messages, ordered by time stamp perform a simple query: function showMessages() {\n DB.Message.find()\n .descending(\"date\")\n .limit(30)\n .resultList()\n .then(function(result) {\n var html = \"\";\n result.forEach(function(msg) {\n html += '<div class=\"col-md-4\"><h2>';\n html += msg.name + '</h2><p>' + msg.message + '</p></div>';\n });\n document.getElementById(\"messages\").innerHTML = html;\n });\n} At this point the application is fully working. Just open the index.html in the browser to use your app. If something is not working, press F12 to see any error messages. Queries allow you do complex filtering and sorting, see the Query Docs . All data loaded from Baqend Cloud is served with low latency from a global CDN.", "title": "Query Data" }, { "location": "/gettingstarted/#protect-your-data", "text": "By default, public access to the Message table is allowed. Let's restrict that to only allow inserts , reads and queries but disallow any updates and deletes . Go to the ACL (Access Control Lists) tab in the dashboard and revoke delete and update rights from the Public role. Access rights can be granted and denied both at table level and at object level. This is explained in detail in the User, Roles and Permissions documentation . Baqend has full SSL support. If you want the Baqend connection to be SSL-encrypted by default, add true as the second parameter of the DB.connect call.", "title": "Protect Your Data" }, { "location": "/gettingstarted/#add-user-registration-and-login", "text": "If you would like your users to login into your application, that's easy. Your app has a predefined User table and the Baqend SDK comes with built-in ways to register and log in users: DB.User.register('john.doe@example.com', 'pwd').then(function() {\n //Now we are logged in\n console.log(DB.User.me.username); //'john.doe@example.com'\n});\n//When coming back, just log in:\nDB.User.login('john.doe@example.com', 'pwd').then(...) You can enable and customize email verification in the settings page of the dashboard. To support OAuth logins (e.g. \"Login with Facebook\"), setup OAuth as described in the User docs , then you can simply call DB.User.loginWithFacebook .", "title": "Add User Registration and Login" }, { "location": "/gettingstarted/#install-the-baqend-cli-and-deploy", "text": "Install the Baqend CLI globally with ( node.js and npm is required): $ npm install -g baqend Deploy your first app version by typing: $ baqend deploy --file-dir . <your-app-name> View it online by visiting your app domain <your-app-name>.app.baqend.com .", "title": "Install the Baqend CLI and Deploy" }, { "location": "/gettingstarted/#start-building", "text": "You can use the app you just created as a baseline for a real app. To explore Baqend's other features: \n Take the Interactive Tutorial \n Read the Developer Guide , to learn about server-side code & validations, push notifications, logging, etc. \n Read the JavaScript API Docs \n Play with the Interative REST API: Open Your App and go to API Explorer \n If you're starting from scratch, have a look at frontend bootstraping tools: Initializr (used here), HTML5 Boilerplate , Bootstrap , Yeoman and popular frontend frameworks: Ionic , AngularJS , React , Ember \n.getting-started-list {\n list-style: none;\n counter-reset: cnt;\n margin-left: 0;\n margin-top: 40px;\n}\n\n.getting-started-list ul li{\n padding: 10px 0;\n}\n\n.getting-started-list h3 {\n margin-top: -110px;\n position: relative;\n z-index: -1;\n}\n\n.getting-started-list>li {\n position: relative;\n border-left: 2px solid #1967CC;\n padding: 0 0 60px 50px;\n /* disable collapsed margin */\n display: inline-block;\n width: 100%;\n}\n\n.getting-started-list>li:last-child {\n border: none;\n}\n\n.getting-started-list>li:before {\n counter-increment: cnt;\n content: counter(cnt);\n position: absolute;\n left: -18px;\n border-radius: 50%;\n background-color: #FFFFFF;\n display: block;\n width: 35px;\n height: 35px;\n line-height: 31px;\n color: #1967CC;\n border: 2px solid #1967CC;\n text-align: center;\n font-size: 21px;\n}", "title": "Start Building" }, { "location": "/", "text": "Baqend Guide\n\n\nLearn how to use Baqend to develop your app.\nJust click a topic below to get more details.\n\n\n\n \n\n \n\n \nTutorial\n\n \nA tutorial how \n to write a to-do \n app with Baqend.\n\n \n\n \n\n \n\n \nQuickstart\n\n \nHow to embed Baqend \n in your JavaScript app \n to get started quickly.\n\n \n\n \n\n \n\n \nStarter Kits\n\n \nSome starter kits for \n popular frameworks \n integrating Baqend.\n\n \n\n \n\n \n\n \nOverview\n\n \nAn overview over \n Baqend's architecture \n and ecosystem.\n\n \n\n \n\n \n\n \nDashboard\n\n \nManage your Baqend \n app's data, schema, \n and settings online.\n\n \n\n \n\n \n\n \nCLI\n\n \nWork with your \n Baqend app from \n your terminal.\n\n \n\n \n\n \n\n \nSetup\n\n \nHow you set up \n and get running \n your first app.\n\n \n\n \n\n \n\n \nCRUD\n\n \nLearn to perform basic \n create, read, update, \n and delete operations.\n\n \n\n \n\n \n\n \nSchema and Types\n\n \nSee how to setup \n your app's data model \n and types.\n\n \n\n \n\n \n\n \nQueries\n\n \nRetrieve specific data \n from Baqend by \n performing queries.\n\n \n\n \n\n \n\n \nReal-Time Queries\n\n \nTrack results of \n complex queries \n in real time.\n\n \n\n \n\n \n\n \nUser Management\n\n \nChange access rights \n by managing users, \n roles, and permissions.\n\n \n\n \n\n \n\n \nBaqend Code\n\n \nWrite server-side \n code and handlers \n in pure JavaScript.\n\n \n\n \n\n \n\n \nPush Notifications\n\n \nSend push notifications \n to inform users \n of your app.\n\n \n\n \n\n \n\n \nDeep Loading\n\n \nLearn how Baqend \n persists your data \n and use deep loading.\n\n \n\n \n\n \n\n \nHosting\n\n \nDeliver your app \n blazingly fast to users \n using Baqend Hosting.\n\n \n\n \n\n \n\n \nFiles\n\n \nUse the file storage to \n upload and download \n files, like images or CSS.\n\n \n\n \n\n \n\n \nCaching\n\n \nLearn how Baqend \n caches your data and \n what it asserts.\n\n \n\n \n\n \n\n \nLogging\n\n \nEase the debbuging \n of your app by \n logging its status.\n\n \n\n\n\n\n\n\n \nNote:\n If you have any questions not answered by this guide, feel free to contact us via \nsupport@baqend.com\n or the chat on the bottom.", "title": "Home" }, { "location": "/#baqend-guide", "text": "Learn how to use Baqend to develop your app.\nJust click a topic below to get more details. \n \n \n Tutorial \n A tutorial how to write a to-do app with Baqend. \n \n \n \n Quickstart \n How to embed Baqend in your JavaScript app to get started quickly. \n \n \n \n Starter Kits \n Some starter kits for popular frameworks integrating Baqend. \n \n \n \n Overview \n An overview over Baqend's architecture and ecosystem. \n \n \n \n Dashboard \n Manage your Baqend app's data, schema, and settings online. \n \n \n \n CLI \n Work with your Baqend app from your terminal. \n \n \n \n Setup \n How you set up and get running your first app. \n \n \n \n CRUD \n Learn to perform basic create, read, update, and delete operations. \n \n \n \n Schema and Types \n See how to setup your app's data model and types. \n \n \n \n Queries \n Retrieve specific data from Baqend by performing queries. \n \n \n \n Real-Time Queries \n Track results of complex queries in real time. \n \n \n \n User Management \n Change access rights by managing users, roles, and permissions. \n \n \n \n Baqend Code \n Write server-side code and handlers in pure JavaScript. \n \n \n \n Push Notifications \n Send push notifications to inform users of your app. \n \n \n \n Deep Loading \n Learn how Baqend persists your data and use deep loading. \n \n \n \n Hosting \n Deliver your app blazingly fast to users using Baqend Hosting. \n \n \n \n Files \n Use the file storage to upload and download files, like images or CSS. \n \n \n \n Caching \n Learn how Baqend caches your data and what it asserts. \n \n \n \n Logging \n Ease the debbuging of your app by logging its status. \n \n Note: If you have any questions not answered by this guide, feel free to contact us via support@baqend.com or the chat on the bottom.", "title": "Baqend Guide" }, { "location": "/topics/overview/", "text": "Overview\n\n\nBaqend Cloud hosts your application data and business logic and delivers it over a \nglobal caching infrastructure\n for performance at the physical optimum. \n\n\nWith Baqend, you use a fully managed backend service with an automatically accelerated \nJavaScript API\n directly from your application (e.g. written in Angular or React). As the platform provides a rich set of turnkey features and takes over the responsibility for backend performance, major development efforts are saved.\n\n\nIn terms of \narchitecture\n Baqend gives you the hosting of your application (e.g. HTML and JS files) plus the APIs for backend concerns such as data storage, queries, push, OAuth, user management, access control and server-side business logic:\n\n\n\n\nGetting Started\n\n\nThese are our recommendations for getting things rolling quickly:\n\n\n\n\nTo get a hands-on overview of how Baqend works, take the \ninteractive tutorial\n\n\nStart your first Baqend app\n and take the Quickstart to build a real application\n\n\nWith the \nStarter Kits\n you get convenient boilerplate projects that work seamlessly with Baqend\n\n\nThis guide covers how Baqend and the SDK work in depth", "title": "Overview" }, { "location": "/topics/overview/#overview", "text": "Baqend Cloud hosts your application data and business logic and delivers it over a global caching infrastructure for performance at the physical optimum. With Baqend, you use a fully managed backend service with an automatically accelerated JavaScript API directly from your application (e.g. written in Angular or React). As the platform provides a rich set of turnkey features and takes over the responsibility for backend performance, major development efforts are saved. In terms of architecture Baqend gives you the hosting of your application (e.g. HTML and JS files) plus the APIs for backend concerns such as data storage, queries, push, OAuth, user management, access control and server-side business logic:", "title": "Overview" }, { "location": "/topics/overview/#getting-started", "text": "These are our recommendations for getting things rolling quickly: To get a hands-on overview of how Baqend works, take the interactive tutorial Start your first Baqend app and take the Quickstart to build a real application With the Starter Kits you get convenient boilerplate projects that work seamlessly with Baqend This guide covers how Baqend and the SDK work in depth", "title": "Getting Started" }, { "location": "/topics/dashboard/", "text": "Baqend Dashboard\n\n\nThe Baqend dashboard is the main tool, which you will use to manage and configure your Baqend instance. After you have\ncreated your first app, you have in the left navigation bar a quick overview over all the configurable and usable \n functionalities of Baqend.\n\n\nHere is a quick overview of those:\n\n\nBaqend Modules\n - can be used to create Baqend code, which can later be called by your app to execute trusted\nbusiness logic. See also \nBaqend Modules\n. By clicking the \n+\n you can create new modules, Afterwards a module \ncode template will be opened.\n\n\nTables\n - are the part where you can create and extend the data model of Baqend to fit your app requirements.\nBy clicking on the class name, you can view and edit the table content and its metadata like schema, access \nrules and code hooks. Each table is represented by one entity class and each row is an instance of this class in the SDK.\nOn the upper right side you can navigate with the tabs through those categories:\n\n\n\n\nData:\n This is the default view of a class and shows the stored instances in a table. You can view, navigate and search \n in the table. In addition you can add new rows, modify fields and delete existing rows. You can im- and export\n the entire table content and truncate (drop all rows) of the table. \nRead More\n\n\nSchema:\n Each class is described by its schema. The schema describes which fields a class have and which type \n those fields have. When you insert data into the table, the data will always be validated against the defined \n schema and modifications which violate the schema will be rejected. Baqend supports many common types, such as \n primitive types, geo points, references, collections, json and embedded types. \nRead More\n\n\nACL (Access Control List):\n In many apps you would like to restrict the access who is allowed to read and write \n the data. Therefore you can restrict the access per operation on class or object level. In this view you can modify \n the access permission for the selected class. You can add new users and roles to the acl and can specify those access \n restrictions. \nRead more\n\n\nHandler:\n are Baqend code hooks, which are invoked before an object is modified. Here you can implement custom\n logic that is invoked every time when an object is inserted, updated or deleted. Within the code you can validate the \n modification, modify some fields or can completely reject the modifications as your needs. \nRead More\n\n\n\n\nThere are three predefined classes which you can also extend with custom fields:\n\n\n\n\nUser:\n are used to represent a user which is logged in into your app. New users can be created by a registration \n process or by a login through an \nOAuth\n provider when configured. \nRead More\n\n\nRole:\n Roles can be created to group users and together and use those groups to give them special privileges \n such as ACLs. There are three predefined roles the admin role, the loggedin role and the node role. Roles contains a predefined users list \n field, which contains all the members of the role. \nRead More\n\n\nDevice:\n represents registered devices which can later be used to send them push notifications out of Baqend\n code. Devices can be queried like any other table to send a push notification to multiple devices at once. \n \nRead More\n\n\n\n\nAdditionally you can create a new custom classes with a click on the \n+\n button near the \nData\n label. Type a none used \nname and hit enter. The schema view will appear and you can begin to model your own class schema.\n\n\nLogs\n - Here you can view the logs generated by accessing the api and your application logs.\n\n\n\n\nAccessLog:\n Each request wich is served by our Baqend servers or the CDN generates a log entry. You can view and \n search in the access logs within a period of 30 days. \nRead More\n\n\nAppLog:\n While developing and later in production is is really common to log specific actions of your app or \n Baqend code for debugging and usage analysis. Therefore the SDK provides a simple logging API that you can use to\n create log entries which are kept for an period of 30 days. \nRead More\n\n\n\n\nAPI Explorer\n - The API Explorer provides a GUI to serve the underlying REST API of Baqend. Here you can explore and\nmade direct HTTP calls to your Baqend server.\n\n\nSettings\n - Her you can configure additional settings of your Baqend app like:\n\n\n\n\nE-Mailing used by the registration process\n\n\nOAuth settings to enable oauth login\n\n\nPush Notifications certificates and keys needed to actually push notifications", "title": "Dashboard" }, { "location": "/topics/dashboard/#baqend-dashboard", "text": "The Baqend dashboard is the main tool, which you will use to manage and configure your Baqend instance. After you have\ncreated your first app, you have in the left navigation bar a quick overview over all the configurable and usable \n functionalities of Baqend. Here is a quick overview of those: Baqend Modules - can be used to create Baqend code, which can later be called by your app to execute trusted\nbusiness logic. See also Baqend Modules . By clicking the + you can create new modules, Afterwards a module \ncode template will be opened. Tables - are the part where you can create and extend the data model of Baqend to fit your app requirements.\nBy clicking on the class name, you can view and edit the table content and its metadata like schema, access \nrules and code hooks. Each table is represented by one entity class and each row is an instance of this class in the SDK.\nOn the upper right side you can navigate with the tabs through those categories: Data: This is the default view of a class and shows the stored instances in a table. You can view, navigate and search \n in the table. In addition you can add new rows, modify fields and delete existing rows. You can im- and export\n the entire table content and truncate (drop all rows) of the table. Read More Schema: Each class is described by its schema. The schema describes which fields a class have and which type \n those fields have. When you insert data into the table, the data will always be validated against the defined \n schema and modifications which violate the schema will be rejected. Baqend supports many common types, such as \n primitive types, geo points, references, collections, json and embedded types. Read More ACL (Access Control List): In many apps you would like to restrict the access who is allowed to read and write \n the data. Therefore you can restrict the access per operation on class or object level. In this view you can modify \n the access permission for the selected class. You can add new users and roles to the acl and can specify those access \n restrictions. Read more Handler: are Baqend code hooks, which are invoked before an object is modified. Here you can implement custom\n logic that is invoked every time when an object is inserted, updated or deleted. Within the code you can validate the \n modification, modify some fields or can completely reject the modifications as your needs. Read More There are three predefined classes which you can also extend with custom fields: User: are used to represent a user which is logged in into your app. New users can be created by a registration \n process or by a login through an OAuth provider when configured. Read More Role: Roles can be created to group users and together and use those groups to give them special privileges \n such as ACLs. There are three predefined roles the admin role, the loggedin role and the node role. Roles contains a predefined users list \n field, which contains all the members of the role. Read More Device: represents registered devices which can later be used to send them push notifications out of Baqend\n code. Devices can be queried like any other table to send a push notification to multiple devices at once. \n Read More Additionally you can create a new custom classes with a click on the + button near the Data label. Type a none used \nname and hit enter. The schema view will appear and you can begin to model your own class schema. Logs - Here you can view the logs generated by accessing the api and your application logs. AccessLog: Each request wich is served by our Baqend servers or the CDN generates a log entry. You can view and \n search in the access logs within a period of 30 days. Read More AppLog: While developing and later in production is is really common to log specific actions of your app or \n Baqend code for debugging and usage analysis. Therefore the SDK provides a simple logging API that you can use to\n create log entries which are kept for an period of 30 days. Read More API Explorer - The API Explorer provides a GUI to serve the underlying REST API of Baqend. Here you can explore and\nmade direct HTTP calls to your Baqend server. Settings - Her you can configure additional settings of your Baqend app like: E-Mailing used by the registration process OAuth settings to enable oauth login Push Notifications certificates and keys needed to actually push notifications", "title": "Baqend Dashboard" }, { "location": "/topics/cli/", "text": "Baqend CLI\n\n\nThe \nCLI\n (Command Line Interface) provides a simple way to:\n\n\n\n\nRegister a Baqend account and start an app \n\n\nDeploy application assets (HTML, images, CSS, etc.)\n\n\nRegister Baqend Code (modules and handlers)\n\n\n\n\nThe Baqend CLI can easily be installed globally with \nnpm install -g baqend\n (to get npm you just need to have \nNode.JS\n installed). Afterwards you can use the CLI\nby typing \nbaqend --help\n in any folder.\n\n\nNote:\n Ensure that your \nPATH\n system enviroment variable contains the global\n \nnpm bin path\n (\n$ npm bin -g\n) to let npm installed commands work properly.\n\n\n\n\nTip:\n A good way to manage a Baqend-based project is to manage the files and collaboration via \ngit\n and using the CLI to deploy files and code to Baqend.\n\n\nThe Baqend CLI is automatically shipped with our SDK. You can use the Baqend CLI directly in any \nnpm script\n.\nTherefore add a Baqend script entry to the scripts section in your projects \npackage.json\n\n\n \"scripts\": {\n \"baqend\": \"baqend\"\n }\n\n\n\n\nAfterwards you can type \nnpm run baqend -- --help\n\n\nNote:\n The extra \n--\n are required to seperate the npm run arguments from the Baqend ones.\n\n\nRegister, Login, and Logout\n\n\nBefore you can actually deploy assets and code you have to create a Baqend account.\nThe easiest way to use it is the \nbaqend register\n command.\nIf you already have an account, you are able login the CLI by typing\n\nbaqend login\n.\nThese commands will save your credentials locally.\n\n\nIf you do not want so save your login credentials, you can skip the login step and provide the login\ncredentials each time you deploy.\n\n\n\n \nNote:\n\n If you have created your Baqend account with OAuth (Google, Facebook, or GitHub), you must add a password to your account first.\n This can be done in the account settings of the dashboard.\n\n\n\n\nYou can logout the Baqend CLI and remove all locally stored credentials by typing \nbaqend logout\n\n\nDeployment\n\n\nWith the \ndeploy\n command, you can upload your static files and assets as well as Baqend Code (modules and handlers) to your Baqend app:\n\n\n$ baqend deploy\n\n\n\n\nDeploying Static Files\n\n\nYou can host the static files and assets of your web app on Baqend.\nTherefore, move your working directory to your app root folder.\nWe expect you to have a folder named \nwww\n by default that is uploaded to the \nwww\n folder in \nBaqend Files\n and served as a website.\n\n\n\n \nTip:\n\n If you want do upload a different directory, you can use the \n--file-dir\n or \n-f\n option to specify a directory:\n \nbaqend deploy --file-dir dist\n.\n\n\n\n\nThe files are then hosted from Baqend.\nRead more about \nBaqend Hosting\n in the \nHosting\n chapter.\n\n\nDeploying Baqend Code\n\n\nThe CLI can additionally deploy your Baqend Code. Baqend code should be located in an folder named \nbaqend\n.\nThe following screenshot visualizes a typical project layout including Baqend code.\n\n\n\n \n\nAll Baqend modules should sit top level within the \nbaqend\n folder.\nFor example, \nbaqend/firstModule.js\n will be uploaded as \nfirstModule\n.\n\n\nFor each code handler you should create a folder named similar to the table \nit belongs to. Within the folder the files should be named:\n\n\nbaqend/<Table>/insert.js\n for an \nonInsert\n handler \n\n\nbaqend/<Table>/update.js\n for an \nonUpdate\n handler \n\n\nbaqend/<Table>/delete.js\n for an \nonDelete\n handler \n\n\nbaqend/<Table>/validate.js\n for an \nonValidate\n handler\n\n\nTherefore \nbaqend/User/insert.js\n contains the insert handler code wich is invoked each time a new user object is inserted\nto the \nUser\n table. \n\n\nRead more about Baqend code in the \nBaqend Code\n chapter.\n\n\n\n\n\nAfter deploying your app, you can open it by typing \nbaqend open\n or use the dashboard with \nbaqend dashboard\n.\n\n\nTypeScript Support\n\n\nThe Baqend SDK itself comes with a \nTypeScript declaration file\n,\nwhich enables seamless integration into TypeScript and allows better code completion.\nThe SDK comes with a dynamic API part, which is generated on the fly depending on your current schema.\nTo make your TypeScript application work properly with this dynamic part you can generate the additional typings for your \ncurrent schema with the CLI.\n\n\nWith \nbaqend typings your-app-name\n the CLI generates the TypeScript declaration file in the current folder.\nYou can then add the generated file to your \ntsconfig.json\n file.\n\n\nYou can update the generated file each time you have changed tables or fields in the Baqend Dashboard by just repeating this step.\n\n\nTip:\n You should check the generated file into your version control system to\n share an up-to-date version of the definition file.", "title": "CLI" }, { "location": "/topics/cli/#baqend-cli", "text": "The CLI (Command Line Interface) provides a simple way to: Register a Baqend account and start an app Deploy application assets (HTML, images, CSS, etc.) Register Baqend Code (modules and handlers) The Baqend CLI can easily be installed globally with npm install -g baqend (to get npm you just need to have Node.JS installed). Afterwards you can use the CLI\nby typing baqend --help in any folder. Note: Ensure that your PATH system enviroment variable contains the global\n npm bin path ( $ npm bin -g ) to let npm installed commands work properly. Tip: A good way to manage a Baqend-based project is to manage the files and collaboration via git and using the CLI to deploy files and code to Baqend. The Baqend CLI is automatically shipped with our SDK. You can use the Baqend CLI directly in any npm script .\nTherefore add a Baqend script entry to the scripts section in your projects package.json \"scripts\": {\n \"baqend\": \"baqend\"\n } Afterwards you can type npm run baqend -- --help Note: The extra -- are required to seperate the npm run arguments from the Baqend ones.", "title": "Baqend CLI" }, { "location": "/topics/cli/#register-login-and-logout", "text": "Before you can actually deploy assets and code you have to create a Baqend account.\nThe easiest way to use it is the baqend register command.\nIf you already have an account, you are able login the CLI by typing baqend login .\nThese commands will save your credentials locally. If you do not want so save your login credentials, you can skip the login step and provide the login\ncredentials each time you deploy. \n Note: \n If you have created your Baqend account with OAuth (Google, Facebook, or GitHub), you must add a password to your account first.\n This can be done in the account settings of the dashboard. You can logout the Baqend CLI and remove all locally stored credentials by typing baqend logout", "title": "Register, Login, and Logout" }, { "location": "/topics/cli/#deployment", "text": "With the deploy command, you can upload your static files and assets as well as Baqend Code (modules and handlers) to your Baqend app: $ baqend deploy", "title": "Deployment" }, { "location": "/topics/cli/#deploying-static-files", "text": "You can host the static files and assets of your web app on Baqend.\nTherefore, move your working directory to your app root folder.\nWe expect you to have a folder named www by default that is uploaded to the www folder in Baqend Files and served as a website. \n Tip: \n If you want do upload a different directory, you can use the --file-dir or -f option to specify a directory:\n baqend deploy --file-dir dist . The files are then hosted from Baqend.\nRead more about Baqend Hosting in the Hosting chapter.", "title": "Deploying Static Files" }, { "location": "/topics/cli/#deploying-baqend-code", "text": "The CLI can additionally deploy your Baqend Code. Baqend code should be located in an folder named baqend .\nThe following screenshot visualizes a typical project layout including Baqend code. \n \nAll Baqend modules should sit top level within the baqend folder.\nFor example, baqend/firstModule.js will be uploaded as firstModule . For each code handler you should create a folder named similar to the table \nit belongs to. Within the folder the files should be named: baqend/<Table>/insert.js for an onInsert handler baqend/<Table>/update.js for an onUpdate handler baqend/<Table>/delete.js for an onDelete handler baqend/<Table>/validate.js for an onValidate handler Therefore baqend/User/insert.js contains the insert handler code wich is invoked each time a new user object is inserted\nto the User table. Read more about Baqend code in the Baqend Code chapter. After deploying your app, you can open it by typing baqend open or use the dashboard with baqend dashboard .", "title": "Deploying Baqend Code" }, { "location": "/topics/cli/#typescript-support", "text": "The Baqend SDK itself comes with a TypeScript declaration file ,\nwhich enables seamless integration into TypeScript and allows better code completion.\nThe SDK comes with a dynamic API part, which is generated on the fly depending on your current schema.\nTo make your TypeScript application work properly with this dynamic part you can generate the additional typings for your \ncurrent schema with the CLI. With baqend typings your-app-name the CLI generates the TypeScript declaration file in the current folder.\nYou can then add the generated file to your tsconfig.json file. You can update the generated file each time you have changed tables or fields in the Baqend Dashboard by just repeating this step. Tip: You should check the generated file into your version control system to\n share an up-to-date version of the definition file.", "title": "TypeScript Support" }, { "location": "/topics/setup/", "text": "Setup\n\n\nWebsites, Apps and Recommended Tooling\n\n\nThe Baqend JavaScript SDK works best for:\n\n\n\n\nDynamic and static \nWebsites\n built with any tools of your choice. We recommend \nsingle page applications\n for the best user experience.\n\n\nHybrid apps\n based on JavaScript. Baqend works very well with \nIonic\n and \nCordova/PhoneGap\n.\n\n\n\n\nThough Baqend does not make any assumptions on the tooling, here a the tools we most frequently see used with Baqend:\n\n\n\n\nFrontend MVC Frameworks\n for structuring your code: \nAngular.js\n, \nAngular2\n, \nReact\n, \nAurelia\n, \nEmber\n and \nKnockout\n\n\nTemplating Engines\n to render data: \nHandlebars\n, \nLodash\n, \nUnderscore\n and \nMustache\n\n\nBoilerplate projects\n and \nfrontend generators\n to get started easily: \nBootstrap\n and \nIntializr\n give you nice boilerplate projects, \nyeoman\n generates many different frontend projects, Google has released a \nweb starter\n that contains a cross-device boilerplate project and useful gulp tasks for live reloading, releasing, etc.\n\n\nHybrid app frameworks\n for mobile applications with JavaScript: \nIonic\n, \nFramework7\n and \nOnsen UI\n are based on web views, \nReact Native\n is based on native UIs with JavaScript logic\n\n\nBuild tools\n for bundling, deployment and development: \nWebpack\n, \nGulp\n and \nGrunt\n all work well with Baqend\n\n\nIDEs\n and \nText Editors\n for developing: \nWebStorm\n and \nNetbeans\n are full-fledged IDEs, \nSublime\n, \nVisual Studio Code\n and \nAtom\n are powerful text and code editors\n\n\nBaqend Starter Kits\n: Boilerplate projects connected to Baqend\n\n\n\n\nJavascript SDK\n\n\nThe JavaScript SDK is packaged as an UMD module, it can be used with RequireJS, browserify or without any module loader.\nTo get started please install the Baqend SDK with \nnpm\n or \nbower\n or \ndownload the complete package from \nGitHub\n.\n\n\nNote:\n If you are not using JavaScript you can use Baqend via its \nREST API\n from the programming language of your choice. Baqend's REST API is documented with \nSwagger\n and can be explored \nhere\n. In the \ndashboard of you Baqend app\n you can goto \"API Explorer\" to explore and use the REST API of your own instance.\n\n\n\nTo install Baqend, just add our CDN-hosted script in your website (available both over HTTPS and HTTP).\n\n\n\n<script src=\"//www.baqend.com/js-sdk/latest/baqend.min.js\"></script>\n\n\n\n\n\nFor additional setup information visit our \nGitHub page\n.\n\n\nTip:\n\nIf you use our \nStarter Kits\n the Baqend SDK is already included and you can skip this setup.\n\n\n\nNote:\n\nIt is generally a good idea to use the latest SDK version from \n//www.baqend.com/js-sdk/latest/baqend.min.js\n in development to always be up-to-date. In production, however, you should use the last exact version you tested with. Be aware that otherwise minor changes in a newly released version may break parts of your production application. See our \nlatest changes\n to the SDK.\n\n\n\nThe Baqend SDK is written and tested for Chrome 24+, Firefox 18+, Internet Explorer 9+, Safari 7+, Node 4+, IOS 7+, Android 4+ and PhantomJS 1.9+\n\n\nThe Baqend SDK does not require any additional dependencies, however it is shipped with a few bundled dependencies:\n\n\n\n\ncore-js, a shim library\n\n\nnode-uuid, A uuid generator\n\n\nvalidator, A validation library\n\n\n\n\nThe Baqend JavaScript SDK and all its bundled dependencies are shipped under the\n\nMIT License\n.\n\n\nTo see that Baqend is working, paste the following after the Baqend script tag. It will replace the HTML body with 5 raw todo items from the \ntutorial application\n. Delete the snippet afterwards.\n\n\n<script>\n DB.connect('toodle').then(function() {\n return DB.Todo.find().limit(5).resultList();\n }).then(function(result) {\n document.querySelector('body').innerHTML = \"<pre>\" + JSON.stringify(result, null, \" \") + \"</pre>\";\n });\n</script>\n\n\n\n\nBaqend + Node.js\n\n\nThe Baqend SDK is fully compatible with \nNode.js\n. This means you can use the SDK in a Node.js-based application for saving data, logging in users, etc. Additionally \nBaqend modules\n and \nhandlers\n are based on Node.js and run and scaled automatically by Baqend.\n\n\nTo install the SDK for a Node.js project do an \nnpm install --save baqend\n and use \nrequire('baqend')\n in your code.\n\n\nvar DB = require('baqend');\nDB.connect('example');\n\n\n\n\nThe Baqend SDK is compatible with Require.JS, Browserify, ES6 and TypeScript and all majors build tools (Gulp, Grunt, Webpack, NPM scripts, etc.).\n\n\nConnect your App to Baqend\n\n\nAfter including the Baqend SDK in your app, connect it with your Baqend. Simply call the connect\nmethod on the DB variable:\n\n\n//connect to the example app\nDB.connect('example');\n//Or use a TLS-encrypted (SSL) connection to Baqend\nDB.connect('example', true);\n\n\n\n\nNote:\n If you use a custom deployment, e.g. the Baqend community edition you must pass a hostname or a complete URL\nto the connect call: \nDB.connect('https://mybaqend.example.com/v1')\n\n\n\nYou can pass a callback as a second argument, which will be called when the connection is successfully established.\n\n\nDB.connect('example', function() {\n //work with the DB\n DB.Todo.load(...)\n});\n\n\n\n\nBehind the scenes Baqend is requested, the metadata of your app is loaded and the \nData Models\n are created and initialized.\nIf you want to register the handler afterwards, you can use the ready method to wait on the SDK initialization.\n\n\nDB.ready(function() { DB... //work with the DB });\n\n\n\n\nIf you are familiar with \nPromises\n you can alternatively use the returned promise instead of passing \na callback. This works for all places in the Baqend SDK that exhibit asynchronous behaviour.\n\n\nDB.ready().then(function() {\n DB... //work with the DB\n});\n\n\