{ Community }
  • Academy
  • Docs
  • Developers
  • Resources
    • Community Articles
    • Apigee on GitHub
    • Code Samples
    • Videos & eBooks
    • Accelerator Methodology
  • Support
  • Ask a Question
  • Spaces
    • Product Announcements
    • General
    • Edge/API Management
    • Developer Portal (Drupal-based)
    • Developer Portal (Integrated)
    • API Design
    • APIM on Istio
    • Extensions
    • Business of APIs
    • Academy/Certification
    • Adapter for Envoy
    • Analytics
    • Events
    • Hybrid
    • Integration (AWS, PCF, Etc.)
    • Microgateway
    • Monetization
    • Private Cloud Deployment
    • 日本語コミュニティ
    • Insights
    • IoT Apigee Link
    • BaaS/Usergrid
    • BaaS Transition/Migration
    • Apigee-127
    • New Customers
    • Topics
    • Questions
    • Articles
    • Ideas
    • Leaderboard
    • Badges
  • Log in
  • Sign up

Get answers, ideas, and support from the Apigee Community

  • Home /
  • BaaS/Usergrid /
avatar image
0
Question by mmitchell413 · Dec 13, 2014 at 07:36 PM · 247 Views baas

Is there a way to add variables to the user entity?

I'm trying to add another variable to the user entity. I want the user to be able to click a button and save their current location for later use. However, I can't seem to be able to find a way to edit the user entity. Right now I am using something like this:

var savedLocation = {
				"latitude": lat,
				"longitude": lng
			};


			var ql = "username='" + username + "'";
			var user = new Apigee.Collection({ 
				'client':client, 
				'type':'users', 
				'qs': {
					'ql': ql 
				}
			});
			user.fetch(
				function(err, data){
					if (err){
						console.log("read failed");				
					}else{
						while(user.hasNextEntity()){
							var currentUser = user.getNextEntity();
							currentUser.savedLocation = savedLocation;
							currentUser.save();
						}
					}
				}
			);


			user.savedLocation = savedLocation;

Is there a way to do this or am just going to have to create a separate database for user's saved locations?

Comment
Add comment Show 1
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Michael Malloy ♦   · Dec 15, 2014 at 08:13 PM 0
Link

I believe that should work. Before I dig into this any further, can you tell me if you are getting a permissions error with this or if the save is just not working?

Close

1 Answer

  • Sort: 
avatar image
0
Best Answer

Answer by Michael Malloy   · Dec 15, 2014 at 09:06 PM

You should be able to add fields to entities of the users collection like any other collection. The only reserved words are username, email and password. Once you find the entity you want to change, set the field name equal to the value you want and save the entity.

Your code looks correct except I don't think user.savedLocation = savedLocation; will work because user is an Apigee collection and not an entity.

Comment
Add comment · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

How to get Group Users using android sdk. 2 Answers

Bass subscriber internal to external 1 Answer

GET on resource not returning anything but Duplicate error on POST 2 Answers

Sync stage data store with production 3 Answers

where can I find "create" and "run query" buttons in the Baas console? 1 Answer

  • Products
    • Edge - APIs
    • Insights - Big Data
    • Plans
  • Developers
    • Overview
    • Documentation
  • Resources
    • Overview
    • Blog
    • Apigee Institute
    • Academy
    • Documentation
  • Company
    • Overview
    • Press
    • Customers
    • Partners
    • Team
    • Events
    • Careers
    • Contact Us
  • Support
    • Support Overview
    • Documentation
    • Status
    • Edge Support Portal
    • Privacy Policy
    • Terms & Conditions
© 2021 Apigee Corp. All rights reserved. - Apigee Community Terms of Use - Powered by AnswerHub
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Spaces
  • Product Announcements
  • General
  • Edge/API Management
  • Developer Portal (Drupal-based)
  • Developer Portal (Integrated)
  • API Design
  • APIM on Istio
  • Extensions
  • Business of APIs
  • Academy/Certification
  • Adapter for Envoy
  • Analytics
  • Events
  • Hybrid
  • Integration (AWS, PCF, Etc.)
  • Microgateway
  • Monetization
  • Private Cloud Deployment
  • 日本語コミュニティ
  • Insights
  • IoT Apigee Link
  • BaaS/Usergrid
  • BaaS Transition/Migration
  • Apigee-127
  • New Customers
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
  • Badges