Skip to content

Commit

Permalink
data maker to save
Browse files Browse the repository at this point in the history
use clojure hashmap pattern when investing in the javascript way of creating datastore record, conversion work is from package

Signed-off-by: Avelino <t@avelino.xxx>
  • Loading branch information
avelino committed Apr 18, 2020
1 parent 8040a83 commit 426ba6a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ lein deps

(defn- main []
(let [ds (datastore/datastore)
data [{:name "created",
:value (.toJSON (new js/Date))}
{:name "name",
:value "Google Cloud Datastore by cljs"}
{:name "url",
:value "https://github.com/avelino/cljs-google-datastore"}]]
data {:created (.toJSON (new js/Date))
:name "Google Cloud Datastore by cljs"
:url "https://github.com/avelino/cljs-google-datastore"}])

;; save data
(datastore/save ds "KEY-NAME" data)
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject cljs-google-datastore "1.0.4"
(defproject cljs-google-datastore "1.0.5"
:description "Google Cloud Datastore client to ClojureScript"
:url "https://github.com/avelino/cljs-google-datastore"
:license {:name "The MIT License"
Expand Down
6 changes: 5 additions & 1 deletion src/cljs_google_datastore/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@
:order order
:limit limit))))

(defn- make-data [data]
(map (fn [[k v]] {:name (name k) :value v}) data))

(defn save
[ds, kind, data]
(let [entity {:key (make-key ds kind), :data data}]
(let [entity {:key (make-key ds kind)
:data (make-data data)}]
(.save ds (clj->js entity))
entity))

0 comments on commit 426ba6a

Please sign in to comment.