Page 1 of 1

Tiggzi database: How can i reference one collection from another

Posted: Wed Jan 23, 2013 8:05 pm
by Lars Eirik

I have made a Tiggzi database, an in one of the collections I have made a column that is supposed to contain references to rows in another collection (i.e. it it should hold a "foreign key"). I guess that this column should be of type "Pointer", but what values should a field of this type contain? The id of the row that its pointing to, or something else?


Tiggzi database: How can i reference one collection from another

Posted: Wed Jan 23, 2013 9:46 pm
by Kateryna Grynko

Hello,
You can find a lot of useful information here: http://docs.mongodb.org/manual/applic...


Tiggzi database: How can i reference one collection from another

Posted: Thu Jan 24, 2013 1:10 am
by maxkatz

Just to add to what Katya said. Here is an example doing a curl command:

code
curl -X PUT
-H "X-Tiggzi-Database-Id: xxxxxxxx....."
-H "X-Tiggzi-Session-Token : xxxxxxxx....."
-H "Content-Type: application/json"
-d '{"review": {"colName":"BookReview", "_id":"xxxxx...."}}' \
https://api.tiggzi.com/rest/1/db/collections/Book/xxxxxx
/code

Pointer type data column look like this:
code
{
"colName": "someCollection",
"_id": "xxxxxxxxxxxxxxxxx......"
}
/code


Tiggzi database: How can i reference one collection from another

Posted: Fri Mar 01, 2013 11:43 pm
by Andrew5567095

{
"id":{
"collName":"Streets",
"id":"2"
}
},
{
"id":{
"collName":"Streets",
"id":"1"
}
},

When trying to query the following pointer records for all records where "_id" = "2", how is the where clause written?

where {"id": {"_id":"2"}}

returns a successful test but the results set is empty......


Tiggzi database: How can i reference one collection from another

Posted: Mon Mar 04, 2013 11:14 am
by Kateryna Grynko

Hi Andrew,

You can create search in database using the following request:code{"id._id": "2"}/code