This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var entity = new Kinvey.Entity({/*attributes*/}, 'collection', { | |
store: 'cached' | |
}); | |
var collection = new Kinvey.Collection('collection', { | |
store: 'cached' | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
navigator.geolocation.getCurrentPosition(function(position) { | |
var coords = position.coords; | |
var entity = new Kinvey.Entity({ | |
_geoloc: [coords.longitude, coords.latitude] | |
}, 'test-collection'); | |
entity.save({ | |
success: function(entity) { | |
// entity is now saved. | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var xhr = new XMLHttpRequest(); | |
xhr.open('GET', 'https://baas.kinvey.com/appdata/kidXXXX', true); | |
xhr.setRequestHeader('Authorization', 'Basic foo:bar'); | |
// Enable the line below to provide Android support. | |
//xhr.setRequestHeader('X-Kinvey-Origin', 'http://www.example.com'); | |
xhr.onload = function() { | |
console.log("LOADED", this.status, this.responseText); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var entity = new Kinvey.Entity('my-collection'); | |
entity.set('key', 'value'); | |
entity.save({ | |
success: function(entity) { | |
var value = entity.get('key'); | |
// value == "value" | |
// Entity is now created, lets update another field. | |
entity.set('foo', 'bar'); | |
entity.save({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Scores collection | |
// [{ user: 'Alice', score: 2 }, | |
// { user: 'Alice', score: 1 }, | |
// { user: 'Bob', score: 4 }] | |
// Create leaderboard | |
var agg = new Kinvey.Aggregation(); | |
agg.on('user'); | |
agg.setInitial({ total: 0 }); | |
agg.setReduce(function(doc, out) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Kinvey.init({ | |
appKey: '<your-app-key>', | |
appSecret: '<your-app-secret>', | |
masterSecret: '<your-master-secret>' | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Step 1: install module. | |
npm install kinvey | |
// Step 2: import the library. | |
var Kinvey = require('kinvey'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script async src="//da189i1jfloii.cloudfront.net/js/kinvey-js-0.9.3.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Hello World</title> | |
</head> | |
<body> | |
<h1>Hello World</h1> | |
<script async src="//da189i1jfloii.cloudfront.net/js/kinvey-js-0.9.1.min.js"></script> | |
<script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var query1 = new Kinvey.Query(); | |
query1.on('_geoloc').nearSphere([-97, 30], 100);// max 100 miles from Austin? | |
var query2 = new Kinvey.Query(); | |
query2.on('_geoloc').nearSphere([-71, 42], 100);// max 100 miles from Boston? | |
var query3 = new Kinvey.Query(); | |
query3.on('population').greaterThan(500000);// large city? | |
// Join all queries, result is saved in query1. |