1
感謝我那可憐的英語技能,我有Ø通過下面這些代碼表達我的想法..如何將集合名稱作爲參數傳遞給Meteor中的方法?
友好編輯:
我想寫一個廣義confirmAndRemoveCollection
方法,這需要在collectionName
和itemId
,我想對這個集合進行操作。由於collectionName
是一個字符串,因此我無法對其執行數據庫操作。有人可以建議我如何使用集合名稱來訪問實際的集合對象。
confirmAndRemoveCollection:(collectionName,itemId)->
check(itemId,String)
check(collectionName,String)
sweetAlert({
title:"confirm"
text:"blabla"
type:"info"
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "delete"
cancelButtonText: "cancel"
closeOnConfirm: false,
},(isConfirm)->
if isConfirm
collectionName.remove(itemId)
else
return
swal(
'success'
"selected item deleted"
"success"
)
是「收集」將是關鍵值屬性的集合(即對象)還是一個對象集合(即一個數組)? – OceansOnPluto