我不确定这是怎么回事。代码在下面,在这里:https://studio.code.org/projects/applab/X4-WurQPCCvEeOYJqYRhps1o55VtifdyI7wAmGuPJKg是应用程序的链接,如果您想尝试的话。任何帮助表示赞赏。
var player = {};
onEvent("addNewRecordButton", "click", function() {
//This code reads the database to create only one user per userID
//If the userID already exists within the database, it does nothing
readRecords("AllUserData", {UserID:(getUserId())}, function(records) {
var count = records.length;
if (count > 1) {
} else if ((count == 1)) {
} else {
player.UserID = getUserId();
player.Username = getText("usernameInput");
createRecord("AllUserData", player, function(record) {
});
}
});
});
onEvent("updateInformationButton", "click", function() {
var player = {};
player.UserID = getUserId();
player.Username = getText("usernameInput");
updateRecord("AllUserData", player.Username, function(record, success) {
if (success) {
setText("label4", "Record updated with id:" +record.id);
setText("label3", player.Username);
} else {
write("Record NOT updated");
}
});
});