1

Documents stored in a collection include a UUID type value when they are inserted and when they are returned from Monger's find-maps function. For example:

{:_id "5515e636314525806f24ceb3"
 :a #uuid "cfda7109-6e50-44c0-b13d-48712f7509a1"}

However when I specify query with this criterion:

(find-maps db collection {:a #uuid "cfda7109-6e50-44c0-b13d-48712f7509a1"})

or this:

(find-maps db collection {:a "cfda7109-6e50-44c0-b13d-48712f7509a1"})

no results are returned. Do I need to use a type converter, or should I just store :a as some other type? Or, perhaps there is some other way?

yakshaver
  • 2,472
  • 1
  • 18
  • 21
  • Not very helpful to say it, but if I store that doc using monger in a test collection, `(find-maps db collection {:a #uuid "cfda7109-6e50-44c0-b13d-48712f7509a1"})` retrieves it successfully for me. – jas May 31 '19 at 10:24

1 Answers1

0

Try converting using the fromString static method of java.util.UUID:

(ns my.project
  (import [java.util UUID]))

(find-maps db collection {:a (UUID/fromString "cfda7109-6e50-44c0-b13d-48712f7509a1")})
Tim Clemons
  • 6,231
  • 4
  • 25
  • 23
  • 2
    Why does this differ from the #uuid reader macro tagged literal version? (avail since clojure 1.4, apparently) – pete23 May 31 '19 at 06:18