Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to set all db queries to only retrieve a given user's entries, or would each query throughout the app have to include "AND user..."?

I created an app that lets users input products and compare them. I am at the point where i need to consider scaling and multiple users, and I want to only show users the items that they've created (instead of the entire db, which may be an option at some point, but for now each user has to create their own lists).

Is there a canned/preferred way of making all queries throughout an app only return entries with the "author" field set to a certain user, the logged in user? Or does every query have to be updated with "AND author..." type filter? Is this what namespaces are for?

I'm using Python on Google App Engine.

like image 607
Max Cascone Avatar asked Jan 04 '11 21:01

Max Cascone


1 Answers

I would suggest looking into namespaces, it is exactly the type of use-case they are well suited for.

One note, if you want to be able to query users all users' products, you may be better off adding an owner property and using query filters. You can't currently query across namespaces -- only within a single namespace at one time.

like image 77
Robert Kluin Avatar answered Sep 21 '22 20:09

Robert Kluin