Page 1 of 2

When to use database pointer type ?

Posted: Wed Aug 21, 2013 11:12 am
by bahar.wadia

I have looked through your documentation, but I am unable to find a clear example or explanation of when one should use the "Pointer" Type col in the database.

Here is what I am attempting to do...

My app has users through the built-in Users collection. I have separately created a UserProfile collection that includes items such as FirstName, Address, Phone number etc. I also have another collection to store multiple pictures per user.

I wish to retrieve a UserProfile Row based on the user that is logged in. Separately, I wish to retrieve multiple pictures based on the user who is logged in.

I know how I would do this in a traditional database.

How best to do this in Appery ?

Thanks for you help.


When to use database pointer type ?

Posted: Wed Aug 21, 2013 11:42 am
by Edwin Schravesande6028557

I guess I sort of understand this now, though I'm not much of a pro.

You'll have to make a pointer in your collection of pictures, that points to the id of either the user table or the id of the user in the extended profile.

How to use this:

  • Save this id you're referring to somewhere as a local variable.

  • query your picture collection, to retreive all pictures. You'll see this response is now extended to the userdata you're pointing to.

    For instance: if you have a collection called userprofile, and a profile key named "firstname", you'll be able to query the pictures, using where {userprofile.firstname = "Ernie"}.

    I might be messing up some of the syntax, but that's the basic idea


When to use database pointer type ?

Posted: Wed Aug 21, 2013 12:10 pm
by Kateryna Grynko

Hi,

Think Pointer realized as a direct connection in the relational database, using the ID. Here is the wrapper for getting nested dependent data without going through the cross requests such as JOIN, which simply is not for this type of database: http://docs.appery.io/documentation/b...


When to use database pointer type ?

Posted: Wed Aug 21, 2013 1:55 pm
by Kateryna Grynko

To use _id as a basis for cross queries - is to create additional queries to the database.

Pointer provides an opportunity to make one request and receive all the user data.

In Users, create the Profile field of type Pointer to UserProfile (in any case, you rely on the User), add the Pictures in the same place as the Pointer to a collection of images.

Then one request for Users using parameter include (http://docs.appery.io/documentation/b... # Including_related_objects) allows to immediately get a User object with the profile, and all the images.


When to use database pointer type ?

Posted: Wed Aug 21, 2013 1:58 pm
by Helsen

Thanks for very useful response.


When to use database pointer type ?

Posted: Fri May 16, 2014 9:41 pm
by anon

is there any way to restrict the attributes returned by the include? For example, I only want to return anything but FirstName, LastName, and Photo from the UserProfile collection


When to use database pointer type ?

Posted: Tue May 20, 2014 12:26 pm
by Maryna Brodina

Hello!

Sorry for a late reply.
We are working on feature which allows to restrict the attributes returned from one collection only. Unfortunately I am not aware is there any plans to add restriction for attributes returned by the include, but let me check. I will update.


When to use database pointer type ?

Posted: Fri May 30, 2014 12:20 pm
by Maryna Brodina

Hello!

Sorry for delay!

Your request has been passed to developers team and they are working on estimation. It might be we include this functionality in the next release, but for now can't say for sure...


When to use database pointer type ?

Posted: Fri May 30, 2014 12:31 pm
by bahar.wadia

I made a suggestion regarding this a few months ago.

Since Appery uses MongoDB, it should be easy because MongoDB supports this functionality.

This limitation effects user experience negatively, especially in applications that are Picture and data intensive.

See my suggestion...

https://getsatisfaction.com/apperyio/...

Thanks


When to use database pointer type ?

Posted: Fri May 30, 2014 1:57 pm
by Maryna Brodina

@bahar.wadia thank you for you input! I will post an update here when have news from developers team.