【问题标题】:How to use Objectify in angularJS javascript如何在 angularJS javascript 中使用 Objectify
【发布时间】:2017-04-20 12:37:30
【问题描述】:

我是 angularjs 编程的新手。我正在尝试将数据插入到 Google Cloud 端点 javascript 但我们可以通过创建新类并添加 objectify 在 java 中进行。 如何在 javascript 中使用类对象并使用 objectify @Id 对字符串进行注释。 当我收到“com.googlecode.objectify.SaveException: Error save com.example.mohanvaradarajan.app: Cannot save an entity with a null String @Id: com.example.mohanvaradarajan.app”错误响应时

$scope.callgapi = function () {
                   $scope.gresult = "Inserting data...";

                   GApi.execute('myApi', 'insert',datanew).then(function (resp) {
                       $scope.gresult = resp.result.data;
                   }, function (resp) {
                       console.log('Error: (' + resp);
                       $scope.gresult="An error has occurred.";
                   });
               }

【问题讨论】:

    标签: javascript html angular google-app-engine objectify


    【解决方案1】:

    问题出在服务器端。您有一个 ID 为 String 的实体,但您没有对其进行初始化。如果您想要自动生成的 id,请使用 Long 作为 id 类型。

    【讨论】:

    • 如何在 javascript 中添加成员类型。 datanew 是 javascript 对象,如下所示 var datanew = {}; datanew.Id = "名称"; datanew.start=“1000”; datanew.end = 1100; datanew.total= 100;
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-09
    相关资源
    最近更新 更多