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
Or install with bower bower install --save-dev baqend
Or download the latest release directly from GitHub.
<script type="text/javascript" src="dist/baqend.js"></script>
<script type="text/javascript" src="dist/baqend.min.js"></script>
You can also include it from our CDN-Provider fastly
.
<script type="text/javascript" src="//www.baqend.com/js-sdk/latest/baqend.js"></script>
<script type="text/javascript" src="//www.baqend.com/js-sdk/latest/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 APP>)
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('example');
DB.connect('example', true);
DB.connect('https://baqend.example.com/v1');
DB.ready(function() {
DB.User.find()
...
});
</script>
Baqend Streaming SDK
If you want to use the realtime streaming queries, you have to either use baqend-streaming.js
or
baqend-streaming.min.js
for production.
In Addition, you must include Rx.js v5 into your project.
As minimal setup, the rxjs Observable is required.
You can use the unpkg CDN:
<script type="text/javascript" src="//unpkg.com/@reactivex/rxjs@5.0.0-rc.2/dist/global/Rx.js"></script>
<script type="text/javascript" src="//www.baqend.com/js-sdk/latest/baqend-streaming.js"></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('example');
DB.ready(function() {
DB.User.find()
...
});
Note: The Baqend Streaming SDK can be required with var DB = require('baqend/streaming');
, ensure that you only
require either the Baqend SDK or the Baqend Streaming SDK and not both.
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('example');
DB.ready(function() {
DB.User.find()
...
});
Note: The Baqend Streaming SDK can be required with var DB = require('baqend/streaming');
, ensure that you only
require either the Baqend SDK or the Baqend Streaming SDK and not both.
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('example');
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