请选择 进入手机版 | 继续访问电脑版
  • 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

MongoDBDrivers: A mongodb driver for Delphi/FreePascal in intermediary stage wit ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

MongoDBDrivers

开源软件地址:

https://gitee.com/yunnet/MongoDBDrivers

开源软件介绍:

MongoDB Driver for Delphi/FreePascal

本人在原有地址上,有加修改,增加了条件语句

原始地址:https://github.com/fabriciocolombo/mongo4delphi

A mongodb driver for Delphi/FreePascal in intermediary stage with a friendly API based on java driver.The delphi native types are mapped onto Delphi Variant and the more complex types (like ObjectId, Array, etc)has an specific implementation.

The driver is tested with Delphi 7, Delphi XE and FreePascal (Lazarus 0.9.30.2/FPC 2.4.4), and probably work fine with another delphi versions above 7.If someone is willing to test with other versions of Delphi, give me feedback and I will update this documentation.For a complete test, compile the source code, run unit tests and make sure the demo works.

The TPC connection may be use Delphi Sockets or Synapse, for compatibility with FreePascal.

Usage:

There are two main units to use to access a mongodb server: mongo.pas e BSONTypes.pas

Code Example Insert:varmongo: TMongo;db: TMongoDB;coll: TMongoCollection;bson: IBSONObject;item: IBSONArray;beginmongo := TMongo.Create;trymongo.Connect(${server.host}, ${server.port});db := mongo.getDB('testdb');coll := db.GetCollection('testcoll');

bson := TBSONObject.NewFrom('code', 123)                   .Put('name', 'Fabricio')                   .Put('LocalDate', Date);item := TBSONArray.NewFrom('awesome')                  .Put(43.29)                  .Put(2012);bson.Put('items', item);coll.Insert(bson);

finallymongo.Free;end;end;

Classe Definition:

The mongo.pas provide the classes:

  • TMongo: Represent the connection to a mongo server, with methods like GetDB(const ADBname: String): TMongoDB
  • TMongoDB: Represent a mongo Database, with methods like RunCommand and GetCollection
  • TMongoCollection: Represent a collection inside a Database, and has methods like: Insert, Update, Remove,CreateIndex, Find, etc.
  • TMongoCursor: Is a cursor to a query results. A cursor allows prepare a query before open, and the main methodsare: Skip, Limit, BatchSize, Count, Size, Sort, Hint, Explain, Snapshot, and for iteration overreturned rows: hasNext and Next;

Then BSONTypes.ps provide the classes what represent documents or value types:

  • IBSONObject: Is the document
  • IBSONArray: An array of values, which may contain other documents
  • IObjectId: An specific implementation to BSON objectId type.
  • Another types could be created

=======


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
下一篇:
ssdb4j: 又一个SSDB的Java驱动发布时间:2022-03-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap