最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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);
发布评论

评论列表(0)

  1. 暂无评论