ubuntu-phone team mailing list archive
-
ubuntu-phone team
-
Mailing list archive
-
Message #09270
Re: Fwd: u1db with sub-field
On Wed, Jul 30, 2014 at 4:19 PM, Yasmany Cubela Medina <yasmanycm@xxxxxxxxx>
wrote:
> Hello everyone
>
> Im writing a ubuntu touch app with u1db as db, but im getting troubles
> with query and index. Im saving a doc with sub-fields, but at retrieve
> point with index and query i wont get the expected resutls. I need the list
> to show two rows one for the account "Ahorro" another one for the account
> "Corriente" but only one row show, the first one.
>
> can anyone help me?
>
I am a bit confused by the code below, are you really trying to model many
accounts in just one document?
"account" is a document id, indexes/indexing takes field names, not
document ids
the natural thing in u1db would be to have one db for accounts, and one
document per account, then index expression would just be:
expression: ["name <http://account.name>"]
another approach is to mix documents of different kinds in the same db, and
use a field "type": "account" etc to distinguish them, and put that in the
index as well
> Here i post my code:
>
> UbuntuListView {
>
> id: accountListView
>
> anchors.margins: units.gu(2)
>
> anchors.top: accountLabel.bottom
>
> anchors.left: parent.left
>
> anchors.right: parent.right
>
> anchors.bottom: parent.bottom
>
> model: accountQuery
>
> delegate: ListItem.SingleValue {
>
> text: contents["name"]
>
> progression: true
>
> onClicked: {
>
> print("clicked")
>
> }
>
> }
>
> }
>
> U1db.Database {
>
> id: myMoneyDB
>
> path: "MyMoney.u1db"
>
> }
>
> U1db.Document {
>
> id: accountDocument
>
> database: myMoneyDB
>
> docId: 'account'
>
> create: true
>
> defaults: {
>
> [
>
> {
>
> "name": "Ahorro"
>
> },
>
> {
>
> "name": "Corriente"
>
> }
>
> ]
>
> }
>
> }
>
> U1db.Index{
>
> database: myMoneyDB
>
> id: accountIndex
>
> expression: ["account.name"]
>
> }
>
> U1db.Query{
>
> id: accountQuery
>
> index: accountIndex
>
> query: "*"
>
> }
>
>
>
> Thanks in advance.
>
> S.U.C.C.E.S.S
> Success is a journey, not a destination.
>
> Ing. Yasmany Cubela Medina:
> Linux user 446757
> Ubuntu user 13464
>
>
> --
> Mailing list: https://launchpad.net/~ubuntu-phone
> Post to : ubuntu-phone@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~ubuntu-phone
> More help : https://help.launchpad.net/ListHelp
>
>
References