Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-25-2020 06:03 PM
I am trying to insert a document into mongodb from Neo4j using apoc, and the document contains a date that I need to be received in mongodb as a date type. Here is an example of what I am sending:
CALL apoc.mongodb.insert('mongodb://localhost:27017','somedb','test',[{runAt: apoc.temporal.format(datetime(), 'ISO_DATE_TIME' )}])
I do receive the document on mongodb, the date is a string, which makes sense (because of apoc.temporal.format) , but I want it to be of type date in mongodb.
I tried almost everything, and I am stuck
Any help is appreciated.
Thanks
06-09-2020 02:48 PM
Hi there,
Have you been able to find a solution for this?
I'm also facing date issues, but to perform a find with parameters within the query, like, "sent after this date". In MongoDB the documents do have the ISODate datatype.
I was able to use operators if I convert a stringified JSON to a map (with apoc), but still never been able to perform a date-related query:
call apoc.mongodb.find('localhost','convofier','recommender_ar',apoc.convert.fromJsonMap('{entry_created_at: {$gt: {$date: "2020-06-03T03:00:00"}}}'),{entry_created_at:1},null,true) yield value
return value
If I use an actual date time, like this:
call apoc.mongodb.find('localhost','convofier','recommender_ar',{entry_created_at: datetime("2020-06-03T03:00:00")},{entry_created_at:1},null,false) yield value
return value
I get
Failed to invoke procedure
apoc.mongodb.find
: Caused by: org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class java.time.ZonedDateTime.
Maybe @michael.hunger can lend us a helping hand here
Looking forward to solving this too
06-09-2020 03:29 PM
use localdatetime insteade of datetime. See below.
call apoc.mongodb.find('localhost','convofier','recommender_ar',{entry_created_at: localDatetime("2020-06-03T03:00:00")},{entry_created_at:1},null,false) yield value
return value
hope it helps
06-09-2020 04:17 PM
Thanks for the prompt reply!
I've tried and got the same error, but with localdatetime at the end:
What version of mongo drivers are you using?
Thanks!
06-10-2020 07:52 PM
Where you able to figure it out?
06-09-2020 04:36 PM
I am using neo4j version 4.0.0 and these plugins:
check your bson version
06-22-2020 12:10 PM
Hi there, thanks for the prompt reply
Unfortunately I haven't been able to run a query filtering by date, neither storing it. I ended up retrieving all records and filtering locally in Neo4j.
I'm using Neo4j 3.5, and MongoDB 3.6 drivers (though I do not have any of the Jackson ones you have )
I will play around with the drivers' versions and let you know.
Thanks again!
All the sessions of the conference are now available online