我有以下结构:
(defrecord Member [id name salary role])
(defrecord Project [id name duration])
(defrecord ProjectMember [project member])
(def project-member-records (ref ()))
(defn find-project-member-record [parm-proj-id parm-member-id]
(filter #(let [project (.project %)
member (.member %)
proj-id (:id project)
member-id (:id member)]
(and (= proj-id parm-proj-id)
(= member-id parm-member-id))) @project-member-records))
;;Sample func, does not work
(defn remove-project-member-record [proj-id member-id]
(dosync (ref-set project-member-records (remove #(= (:id (.project %)) proj-id) @project-member-records))))
现在,我想从中删除项目project-member-records
。例如,我想按项目 ID 和成员 ID 删除项目,就像我在find-project-member-record
函数中查找记录一样。或者(和)我想删除比我找到的记录的项目project-member-records
,比如(remove (find-project-member-record 1 1) project-records) ;pseudo code
但我不知道我该怎么做。