1

更新 3这适用于 Clozure Common Lisp我随后在 SBCL 中尝试了这个,它使用最新的 mongo-community 没有问题。

我正在关注Lisp for the Web这本书进展顺利。现在我已经到了使用 mongodb 的部分,我的经验有限。我没有成功使用cl-mongo 从 CCL 连接到 mongo。我已经按照说明mongodb-community通过brew和点击进行了安装,并在命令行发出将我带到 mongo shell,所以它看起来确实安装好了。mongodb/brewmongo

但是从 CCL 尝试连接我得到这个:

(奇怪的是,当我(db.use "test")第一次发出时它总是因连接被拒绝而失败,然后在“出现错误”时第二次发出时不会抱怨,如下所示)。

(我完全不清楚发出“在错误中”的表达的真正含义,或者人们可以在那里明智地做些什么——任何帮助都会很棒,包括如何了解更多相关信息)。

CCL is free software.  It is distributed under the terms of the Apache
Licence, Version 2.0.
? (ql:quickload '(:cl-mongo))
To load "cl-mongo":
  Load 1 ASDF system:
    cl-mongo
; Loading "cl-mongo"

(:CL-MONGO)
? (use-package :cl-mongo)
T
? (db.use "test")
> Error: Error #<USOCKET:CONNECTION-REFUSED-ERROR #x30200262ED9D>
> While executing: USOCKET::RAISE-ERROR-FROM-ID, in process listener(1).
> Type :POP to abort, :R for a list of available restarts.
> Type :? for other options.
1 > (db.use "test")
"test"
1 > (db.insert "foo" (kv "document" "one"))
error occured when sending message : There is no applicable method for the generic function:
  #<STANDARD-GENERIC-FUNCTION USOCKET:SOCKET-STREAM #x30200244649F>
when called with arguments:
  (NIL)
closing connection (type-of MONGO) [name : DEFAULT ] 
 {[id : 9FB20354-9DFF-41E5-B2C6-737F0D7D2FB0] [port : 27017] [host : localhost] [db : test]} 


 unable to close mongo connection for mongo connection (type-of MONGO) [name : DEFAULT ] 
 {[id : 9FB20354-9DFF-41E5-B2C6-737F0D7D2FB0] [port : 27017] [host : localhost] [db : test]} 
: error There is no applicable method for the generic function:
  #<STANDARD-GENERIC-FUNCTION USOCKET:SOCKET-CLOSE #x30200244095F>
when called with arguments:
  (NIL)
NIL
1 > 

这是我mongo在 shell 中输入时得到的

mbp:lispforweb m$ mongo
MongoDB shell version v4.2.1
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("acd39568-e862-4a2d-8dcf-45409f11e029") }
MongoDB server version: 4.2.1
Server has startup warnings: 
2019-11-17T23:02:18.194+0000 I  CONTROL  [initandlisten] 
2019-11-17T23:02:18.194+0000 I  CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-11-17T23:02:18.194+0000 I  CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2019-11-17T23:02:18.194+0000 I  CONTROL  [initandlisten] 
---
Enable MongoDB's free cloud-based monitoring service, which will then receive and display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).

The monitoring data will be available on a MongoDB website with a unique URL accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.

To enable free monitoring, run the following command: db.enableFreeMonitoring()
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---

> exit
bye
mbp:lispforweb m$ 

更新:我无法使用系统上旧版本的 Robo3T 进行连接,直到我将其升级到最新版本,以反映 mongo v4.x。由于 cl-mongo 几年没碰过,可能是不兼容 mongodb v.4.x 吧?(一个推测)。

更新 2:我将 mongo 降级为 mongodb-community@3.2,我遇到了同样的问题。mongo-cl 的 github 页面上的一个问题表明 mongo-cl 与 mongodb > v.3.0 不兼容,并且似乎不再支持 3.2 以下的版本(可在 mongo brew tap 上获得)。3.2 是最旧的可用版本。

4

0 回答 0