bmob / bmob-flutter-sdk

Bmob Flutter SDK
49 stars 26 forks source link

query.setOrder("-createdAt");不起作用哦。 #19

Open AllLuckly opened 5 years ago

AllLuckly commented 5 years ago
  ///查询关联数据
  _queryPointer() {
    BmobQuery<Diary> query = BmobQuery();
    query.setInclude("author");
    query.setOrder("-createdAt");
    query.queryObjects().then((data) {
      List<Diary> blogs = data.map((i) => Diary.fromJson(i)).toList();
      print(blogs);
      for (Diary blog in blogs) {
        if (blog != null) {
          print(blog.objectId);
          print(blog.title);
          print(blog.content);
          if (blog.author != null) {
            print("rrrr"+blog.author.objectId + " yyyyyy "+ userId + blog.author.objectId.compareTo(userId).toString());
            if(blog.author.objectId.compareTo(userId) == 0){
              restaurants.add(blog);
              print(blog.author.objectId + "rrrr");
            }

          }
        }
      }
      setState(() {

      });
    }).catchError((e) {
      DataPlugin.toast(BmobError.convert(e).error);
    });
  }