Baqend JavaScript SDK
Setup
To use the Baqend SDK, just include the baqend.js or baqend.min.js from the dist folder
at the bottom of your body.
Alternatively you can install the Baqend SDK with npm. Just type npm install --save-dev baqend
<script type="text/javascript" src="dist/baqend.js"></script>
<script type="text/javascript" src="dist/baqend.min.js"></script>
The Baqend SDK provides a global DB
variable by default.
Initialize
Before you can actually use the Baqend SDK, you must link the Baqend SDK to your Baqend Account.
Just call DB.connect(<your Baqend URI>)
after including the Baqend SDK.
The Baqend SDK connects to your Baqend and initialize the SDK. If the connection was successfully established
the ready callback will be called and the DB can be used to load, query and save objects.
<script type="text/javascript" src="baqend.js"></script>
<script type="text/javascript">
DB.connect('https://example.baqend.com');
DB.ready(function() {
DB.User.find()
...
});
</script>
Usage in Node.js
The Baqend SDK can also be used in Node.js. Just do an npm install --save baqend
and use require('baqend')
in your code.
var DB = require('baqend');
DB.connect('https://example.baqend.com');
DB.ready(function() {
DB.User.find()
...
});
Just install baqend with npm install --save-dev baqend
, require('baqend')
in your code
and build the Baqend SDK + your code with browserify.
var DB = require('baqend');
DB.connect('https://example.baqend.com');
DB.ready(function() {
DB.User.find()
...
});
Type browserify scripts/main.js > scripts/bundle.js
to build your main.js script.
For more advanced building steps visit the browserify Documentation.
Use the Baqend SDK from the /dist folder or install the SDK via npm npm install --save-dev baqend
.
Add the Baqend SDK as a dependency of your script and use the required Baqend SDK.
require(["scripts/baqend.js"], function(DB) {
DB.connect('https://example.baqend.com');
DB.ready(function() {
DB.User.find()
...
});
});
For more advanced usage of requirejs visit the requirejs Documentation.
License
This Baqend SDK is published under the very permissive MIT license