Erste Praxiserfahrungen mit Backend as a Service

Seite 6: Beispiel für Azure

Inhaltsverzeichnis
<!DOCTYPE html>
<html>

<head>
<script src='http://ajax.aspnetcdn.com/ajax/mobileservices/
MobileServices.Web-1.1.0.min.js'></script>
</head>

<body>
<script>
var personTable;

function init() {
var MobileServiceClient = WindowsAzure.MobileServiceClient;
var client = new MobileServiceClient('https://testapp42.azure-
mobile.net/', 'dZSmjfaURRNbxOlvAhXlRZXiHiGxvx97');
var personTable = client.getTable('Person');
}

function store() {
personTable.insert({
vorname: "Max",
nachname: "Mustermann",
alter: 35
}).done(function (result) {
console.log(JSON.stringify(result));
}, function (err) {
console.log("Error: " + err);
});
}

function fetch() {
var query = personTable.where({
id: "A2D2C923-4947-401F-AAB4-7A90D274A3EF"
}).read().done(function (results) {
console.log(JSON.stringify(results));
}, function (err) {
console.log("Error: " + err);
});
}

function query(vorname) {
var query = personTable.where({
vorname: vorname
}).read().done(function (results) {
console.log(JSON.stringify(results));
}, function (err) {
console.log("Error: " + err);
});
}
</script>
</body>

</html>