mongoDB plugin for QML
here is the mongoDB plugin for QtQuick
import QtQuick 2.0 import me.qtquick.MongoDB 0.1 Rectangle { id: root width: 360 height: 360 Database { id: db host: '127.0.0.1' port: 27017 name: 'test' property Collection test: Collection { name: 'test' } } TextInput { id: text anchors.left: parent.left anchors.right: parent.right anchors.top: parent.top Keys.onReturnPressed: { db.test.insert(JSON.parse(text.text)) text.text = '' } Text { id: placeholder text: qsTr('enter {"key": "value"} here then press return key') font: parent.font color: Qt.lighter(parent.color) opacity: 0.0 states: State { when: text.text.length === 0 && !text.focus PropertyChanges { target: placeholder opacity: 0.75 } } transitions: Transition { NumberAnimation { property: 'opacity' } } } } ListView { anchors.top: text.bottom anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom clip: true // model: db.test.find({x: {$exists: 1}, j: {$exists: 1}}).skip(5).limit(5).sort({j: -1}) model: db.test.find() delegate: Text { text: JSON.stringify(model.modelData) } } }
$ git clone git://git.qt-users.jp/codereview/qmlplugins/mongodb.git $ cd mongodb $ git submodule update --init $ qmake $ make $ (sudo) make install $ qmlscene ./examples/examples.qml
contributions are always welcome!
see http://qtquick.me/ for details