QEjdbClient QML Type

Client interface to access ejdb service. More...

Import Statement: import QtEjdb 1.0
Since: QtEjdb 1.0

Properties

Methods

Detailed Description

import QtEjdb 1.0

QEjdbClient connects an ejdb. It is used for all communication with the QtEjdb backend.

QEjdbClient {
    id: client
    uri: 'file:test_db'
}

An client can connect an ejdb with an uri or a connectionName. With a connectionName you can connect an previous opened connection.

// c++
QEjdbDatabase::addDatabase("file:test_db", "myconnection");
// qml
QEjdbClient {
    id: client
    connectionName: 'myconnection'
}

Property Documentation

connectionName : QString

Open a database from an already opened QEjdbDatabase.


uri : QString

Open a database from uri.

QEjdbClient {
    id: client
    uri: 'file:test_db'
}

Method Documentation

void createCollection(QString collectionName)

Creates a collection with name.


QJSValue load(QString collectionName, QJsValue uid)

Loads a bson with his id. If no bson found an empty json is returned.


void query(QString collectionName, QJsValue query, QJsValue hints)

Get an array with json from collection. Desciption about building queries and hints see http://ejdb.org/doc/ql/ql.html


void remove(QString collectionName, QJsValue id)

Removes a json with from collection.


void removeCollection(QString collectionName)

Removes a collection with name.


QJsValue save(QString collectionName, QJSValue json)

Saves a bson in a given collection. The returned json have a _id property with a generated bson id.

function saveBson() {
    client.createCollection('person')
    var json = client.save('person', {name: 'Edgar Marx', age: 5})
    console.log(json._id)
    var edgar = client.load('person', json._id)
}