javascript - How to query by date in react realm? - Stack Overflow

I have a table called visitDetails, which I'm querying as follows,realm.objects("visitDetail

I have a table called visitDetails, which I'm querying as follows,

realm
.objects("visitDetails")
.filtered("visitDate='"+new Date(response.date)+"' AND chemistId='"+response.chemist_id+"'");

I have saved the visitDate as date objects before, so I'm also querying by date objects. I'm however, getting as error saying,

Error: You must pass in a date argument to pare

But I'm already passing in a date argument...

new Date( response.date )

, where response.date is in milliseconds.

I have a table called visitDetails, which I'm querying as follows,

realm
.objects("visitDetails")
.filtered("visitDate='"+new Date(response.date)+"' AND chemistId='"+response.chemist_id+"'");

I have saved the visitDate as date objects before, so I'm also querying by date objects. I'm however, getting as error saying,

Error: You must pass in a date argument to pare

But I'm already passing in a date argument...

new Date( response.date )

, where response.date is in milliseconds.

Share Improve this question asked Aug 3, 2017 at 6:17 Abhishek AcharyaAbhishek Acharya 3294 silver badges13 bronze badges 1
  • Abhishek what can you tell me how did you save the date in the realm. The property is date type right? and in which format did you save? – Omer Commented Dec 17, 2017 at 12:27
Add a ment  | 

2 Answers 2

Reset to default 6

Right now you are casting the Date object to a string by concatenate it with a string. You should do something like this

realm.objects('visitDetails').filtered(
  "visitDate = $0 AND chemistId = $1",
  new Date(response.date),
  response.chemist_id
);

Quick solution here. You should pass date as parameter.

.filtered("visitDate = $0 AND chemistId = $1", new Date(response.date), response.chemist_id);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742359378a4429084.html

相关推荐

  • javascript - How to query by date in react realm? - Stack Overflow

    I have a table called visitDetails, which I'm querying as follows,realm.objects("visitDetail

    3小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信