Page 1 of 2

Restaurant menu

Posted: Thu Dec 26, 2013 10:10 pm
by Bert Vandenbogaerde

How can i do the following:

I want to create a restaurant menu.
It contains 3 types of food(fish, meat, italian) and each type of food has several (15 to 20) dishes.

I want to use the database.

I think it has t do with “pointer type” but i dont understand the tutorials concerning the “pointer type”.

Can you give me an exapmle?


Restaurant menu

Posted: Thu Dec 26, 2013 10:36 pm
by Illya Stepanov

Hi Bert,

What tutorial you are referring to?


Restaurant menu

Posted: Thu Dec 26, 2013 10:38 pm
by Bert Vandenbogaerde

Restaurant menu

Posted: Fri Dec 27, 2013 1:27 am
by Illya Stepanov

Example:
We have User with id === "51dba907e4b0cb6cf9c0ba24",
We have collection with column "owner" with type Pointer to Users (pointer)
So if we want retrieve all items with owner "51dba907e4b0cb6cf9c0ba24" we must use this query:
precode
{
"owner": {
"$inQuery" : {
"id": "51dba907e4b0cb6cf9c0ba24"
}
}
}
/code/pre

$inQuery is well described here.

Should also be useful following topics:
:: https://getsatisfaction.com/apperyio/...
:: https://getsatisfaction.com/apperyio/...


Restaurant menu

Posted: Fri Dec 27, 2013 9:58 am
by Bert Vandenbogaerde

I am getting close.

How can i point to more than one id in another database collection?


Restaurant menu

Posted: Fri Dec 27, 2013 10:15 am
by Maryna Brodina

Hello! In other words you want to have a field in one collection which refers to objects array in other collections? For this purpose it's better to create for each object separate field with pointer type.


Restaurant menu

Posted: Fri Dec 27, 2013 10:39 am
by Bert Vandenbogaerde

This is the situation:

the menu contains 3 types of food(fish, meat, italian) and each type of food has several (15 to 20) dishes.

so i created a database collection for the 3 types of food and a collection with all the dishes for the 3 types of food.

In the database collection with the types of food i created a pointer to the dishes database collection.
I can connect 1 ID but of course i have to point to more than one dish.

What is the best approach?


Restaurant menu

Posted: Fri Dec 27, 2013 12:19 pm
by Maryna Brodina

What is the difference between type of food (fish, meat, italian)? If they have the same fields it's better to use for them the same collection where will be specified type of food, if the have different - then it's better to store type value in collection with pointer to food.


Restaurant menu

Posted: Fri Dec 27, 2013 1:51 pm
by Bert Vandenbogaerde

i created two database collections:

Image

Image

The first has a pointer field to the second with values 1 and 2 which correspond to the id field (made it an index column) in the second.

First i list the "section" column on my first page: (through list service)

Image

How can i do the following tasks:
when i click on "kazen" it has to go to a detail page and list all the items with id "2" of the second database collection, "kanas". And when i click on "nagerechten" it has to go to a detail page and list all the items with id "1" of the second database collection, "foie gras" and "ganzenlever".


Restaurant menu

Posted: Sat Dec 28, 2013 5:44 am
by Igor

Hello,

Below tutorial will help you.
http://docs.appery.io/tutorials/build...