Haskell 有没有办法从持久化mongoDB使用低级mongoDB后端?
在persistent的SQL版本中,直接访问SQL似乎是通过Haskell 有没有办法从持久化mongoDB使用低级mongoDB后端?,haskell,yesod,Haskell,Yesod,在persistent的SQL版本中,直接访问SQL似乎是通过rawSql完成的。是否有类似的方法从mongoDB后端访问低级命令?结果比我想象的要简单得多。只需导入Database.MongoDB并在runDB中使用原始驱动程序命令。例如: import Database.MongoDB ... postCommentR :: DocumentId -> Handler Value postCommentR documentId = do comment <- commentO
rawSql
完成的。是否有类似的方法从mongoDB后端访问低级命令?结果比我想象的要简单得多。只需导入Database.MongoDB
并在runDB中使用原始驱动程序命令。例如:
import Database.MongoDB
...
postCommentR :: DocumentId -> Handler Value
postCommentR documentId = do
comment <- commentOr400
let idString = toPathPiece documentId
contents = commentBody comment
runDB $ DB.modify (DB.select ["_id" DB.=: idString] "Document") ["$push" DB.=: ["comments" DB.=: contents]]
returnJson $ object []
import Database.MongoDB
...
postCommentR::DocumentId->处理程序值
postCommentR documentId=do
注释可能的重复我不认为这是重复的,因为另一个问题并没有提到使用MongoDB的DirectAPI。