在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称: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:
Then BSONTypes.ps provide the classes what represent documents or value types:
======= |
请发表评论