Back4app解析服务器:查找仅获取ID而不是所有数据

时间:2018-11-03 01:50:49

标签: vue.js parse-server back4app

我在查找位置,因为Parse.query的结果只是id,我还有其他列:(

查找响应:

 [{"_objCount":0,"className":"DivorceCase","id":"8Ab15ASBX3"}]

实际代码:

// Your corresponding keys
    Parse.initialize("xxx", "xxx");
// For back4app applications
    Parse.serverURL = 'https://parseapi.back4app.com'

var app = new Vue({
        el: "#AttorneyCases",
        data: {             
    DivorceCase :{},      
        },
  mounted:function(){
    new Parse.Query("DivorceCase").descending("createdAt").find()
    .then((DivorceCaseResponse) => {
      this.DivorceCase = DivorceCaseResponse;
    })
  }
  })

2 个答案:

答案 0 :(得分:2)

要获取其他列字段的值,您需要使用以下代码:

var columnName = DivorceCaseResponse.get("columnName");

您可以查看有关获取对象here的更多信息。

答案 1 :(得分:1)

谢谢,纳塔利克!

最终代码是:

   `mounted:function(){       
    var Case = Parse.Object.extend("DivorceCase");
    var query = new Parse.Query(Case);
        query.find()
    .then((Ids) => {

     Ids.forEach(element => {

      var Case = Parse.Object.extend("DivorceCase");
      var query = new Parse.Query(Case);
          query.get(element.id)
              .then((DivorceCaseResponse) => {
                // The object was retrieved successfully.
                this.DivorceCases.push(DivorceCaseResponse.get("BasicInfo"));
              },
              (e) => {
                // The object was not retrieved successfully.
                // error is a Parse.Error with an error code and message.
                swal({
                          position: 'center',
                          type: 'error',
                          title: e.message,
                          customClass: 'swal-wide'
                    })
              });

     });



    },
     (e) => {
      // The object was not retrieved successfully.
      // error is a Parse.Error with an error code and message.
      swal({
                                    position: 'center',
                                    type: 'error',
                                    title: e.message,
                                    customClass: 'swal-wide'
                                })

    });


  }`