mongo-d-driver 介绍
mongo-d-driver 是 MongoDB 的 D
语言开发包。
示例代码:
/* * make: dmd -version=D2 -Iexport libmongod-D2.a example/connect.d * * -Iexport : path to the folder containing the files: * bson.di, bson_h.di, md5.di, mongo.di, mongo_h.di, myversion.di, net.di, numbers.di */ module example; import std.stdio; private import mongod.mongo_h; private import mongod.mongo; private import mongod.bson_h; private import mongod.bson; void main(char[][] args) { mongo conn; string collection = "test"; string host = "localhost"; int port = 27017; char* col = cast(char*) collection; char* ns = cast(char*) (collection ~ ".simple"); try { mongo_connect(&conn, host, port); writeln("connect to mongodb [", host, ":", port, "] sucessful"); mongo_set_op_timeout(&conn, 1000); } catch (Exception ex) { writeln("Failed to connect to mongodb, err=", ex.msg); } }
mongo-d-driver 官网
https://github.com/itiu/mongo-d-driver
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。