bahar.wadia
Posts: 0
Joined: Wed Aug 07, 2013 2:05 am

When to use database pointer type ?

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.

Edwin Schravesande6028557
Posts: 0
Joined: Tue Jul 09, 2013 2:44 pm

When to use database pointer type ?

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

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

When to use database pointer type ?

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...

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

When to use database pointer type ?

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.

Helsen
Posts: 0
Joined: Wed Jul 31, 2013 1:42 pm

When to use database pointer type ?

Thanks for very useful response.

anon
Posts: 0
Joined: Sun Apr 13, 2014 12:10 am

When to use database pointer type ?

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

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

When to use database pointer type ?

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.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

When to use database pointer type ?

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...

bahar.wadia
Posts: 0
Joined: Wed Aug 07, 2013 2:05 am

When to use database pointer type ?

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

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

When to use database pointer type ?

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

Return to “Issues”