更新3 :这适用于Clozure Common Lisp 。 我随后在SBCL中尝试了此方法,并且使用最新的mongo-community,它没有任何问题。
我正在关注进展顺利的Lisp for the Web这本书。现在,我进入了使用mongodb的部分,我对此有有限的经验。我无法使用cl-mongo从CCL连接到mongo。我通过mongodb-community
安装了brew
,并按照instructions的方式mongodb/brew
轻按了该命令,并在命令行中发出mongo
将我带到了mongo shell,所以看起来安装成功。
但是从尝试连接的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 >
这是我在shell中键入mongo
时得到的结果
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进行连接,直到将其升级到最新版本以反映mongov4.x。由于cl-mongo几年没有被使用过,也许它与mongodb v.4.x不兼容? (一个猜测)。
更新2 :我将mongo降级为mongodb-community@3.2,并且遇到了同样的问题。 mongo-cl的github页面上的issue表明mongo-cl与mongodb> v.3.0不兼容,并且不再支持3.2以下的版本(可在mongo brew tap上使用)。 3.2是最旧的。