Code Monkey home page Code Monkey logo

pebongo's Introduction

pebongo

the first mongodb driver for delphi/FPC

MongoDB driver for delphi and freepascal. Synapse (blocking TCP Socket) is used for compatibility with freepascal.

Current

  • JSON Parser
  • BSON I/O (done)
  • Wire Protocol Implementation (in progress)

TODO

ordered by priority

  • create test code and code examples (always)
  • implement mongodb protocol (in progress)
  • create tool to convert BSON-JSON and vice versa (BSON->JSON ok)
  • create documentation (tutorial, reference)
  • create db navigator app

Code Example

//example #2 on bsonspec.org
var
  bson              : TBSONDocument;
  item              : TBSONArrayItem;
begin
  bson := TBSONDocument.Create;
  item := TBSONArrayItem.Create;
  item.Items[0] := TBSONStringItem.Create( 'awesome' );
  item.Items[1] := TBSONDoubleItem.Create( 5.05 );
  item.Items[2] := TBSONIntItem.Create( 1986 );
  bson.Values['BSON'] := item;
  bson.SaveToFile( ExtractFilePath( Application.ExeName ) + 'hello.bson' );
  bson.Free;
//preliminary driver interface
var
  mongo             : TMongoConnection;
  coll              : TMongoCollection;
  cursor            : TMongoCursor;
  i                 : integer;
begin
  mongo := TMongoConnection.Create;
  memo1.lines.add( booltostr( mongo.Connected, true ) );
  mongo.GetDatabase( 'tesdb' );
  coll := mongo.GetCollection( 'things' );
  cursor := coll.find( );

  memo1.lines.add( inttostr( cursor.Count ) );
  for i := 0 to cursor.Count - 1 do
    memo1.lines.add( cursor.Result[i].ToString );//print as JSON

  cursor.Free;
  coll.Free;
  mongo.Free;
end;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.