google-cloud

Google Cloud Platform: Clojure + {GAE, GCE, anything else on Google Platform}
2019-04-30T14:00:46.000200Z

hey guys

2019-04-30T14:01:03.000700Z

I'm using datastore interop and I want to store an array

2019-04-30T14:01:14.001Z

No matching method set found taking 2 args for class
   com.google.cloud.datastore.Entity$Builder

2019-04-30T14:01:55.001700Z

this is the error for:

(create "aaaa" {:a [1 2 3]})
using:
(defn create
  "Takes a map of keyword-value pairs and puts a new Entity in the Datastore.
  The map must include a :kind String.b
  Returns the saved Entity converted with entity-to-map (which will include the assigned :key)."
  [kind item]
  (let [kind-key       (-> kind clojure.string/lower-case (str "-id") keyword)
        key-built      (.build (Key/newBuilder ^Key (.newKey (keyFac kind) (epoch-now))))
        id             (.getId key-built)
        kind-id        (.getId (.allocateId dataStore (.newKey (keyFac kind))))
        properties     (dissoc item kind-key)
        new-properties (merge properties {kind-key kind-id})
        entity         (Entity/newBuilder ^Key key-built)
        transaction    (.newTransaction dataStore)]
    (doseq [[prop-name value] new-properties]
      ;; doing cond for type hinting to .set for datastore
      (log/info prop-name)
      (log/info value)
      (prn value)
      (cond (nil? value) nil
            (= java.util.Date (class value))
            (.set ^Entity entity (name prop-name) ^Date value)
            (coll? value) (.set ^Entity entity (name prop-name) (into-array value))
            :else        (do (.set ^Entity entity (name prop-name) value))))
    (.put transaction (.build entity))
    (.commit transaction)))
`

2019-04-30T14:02:20.002200Z

if someone could help me, please

2019-04-30T14:11:38.003100Z

I saw that in javadoc of com.google.cloud.Datastore.Entity$Builder I can do this: