Xbasic

Extension::MongoDB Class

Description

MongoDB client, allows direct CRUD calls to a mongoDB server.

Properties

collectionCharacter

String collection property

baseURLCharacter

String baseURL property

databaseCharacter

String database property

errorTextCharacter

String errorText property

usernameCharacter

String username property

passwordCharacter

String password property

certificateCharacter

String certificate file, if set to 'none' then the default behavior of the client library will be used.

query_limitNumeric

Numeric query_limit property. If value is greater that 0, the number of records returned by GetRecords or GetAllRecords will be limited to the specified number.

Example

dim mongo as extension::MongoDB = extension::MongoDB::Create("mongodb://localhost:27017","Northwinds","Customers")
mongo.query_limit = 2
mongo.formatJson = .t.
? mongo.GetRecords("","","{ \"_id\" : 0 ,\"CustomerID\" : 1 }")
= [
    {
        "CustomerID": "ALFKI"
    },
    {
        "CustomerID": "ANATR"
    }
]
query_skipNumeric

Numeric query_skip property. If greater than zero, GetRecords and GetAllRecords with skip the first query_skip document records.

Example

dim mongo as extension::MongoDB = extension::MongoDB::Create("mongodb://localhost:27017","Northwinds","Customers")
mongo.query_skip = 2
mongo.query_limit = 2
mongo.formatJson = .t.
? mongo.GetRecords("","","{ \"_id\" : 0 ,\"CustomerID\" : 1 }")
= [
    {
        "CustomerID": "ANTON"
    },
    {
        "CustomerID": "AROUT"
    }
]
formatJsonLogical

Logical formatJson property - if set to true, automatically reformats the produced JSON.

Methods

AddRecord Method

Adds a document db record using 'id'.

BulkOperation Method

Bulk add/remove/update record operation.

Create Method

Create a mongo object.

CriteriaToJavascript Method

Converts Mongo DB style JSON criteria into a javascript comparison expression where variables are under 'doc'.

DeleteRecord Method

Deletes a document db record using 'id'.

DropCollection Method

Drop a collection.

DropDatabase Method

Delete the mongo database.

GetAllRecords Method

Gets all records for a document database.

GetRecord Method

Gets a document db record using 'id'.

GetRecords Method

Get records from mongo collection that match the criteria spec.

ListCollections Method

Get collections in the current database.

ListDatabases Method

Get top level database list.

MapReduce Method

Get result of a map/Reduce against a mongo collection.

RenameCollection Method

Rename a collection.

UpdateRecord Method

Updates a document db record using 'id'.

See Also