PDA

View Full Version : Initial loading of data & users into Sencha.io



khooten
10 Apr 2013, 7:29 AM
I have an app that I'm porting from an older system that has thousands of active users. Can I create users and groups with the API as opposed to using the Dashboard interface?

Also, each user has current and historical data in this application. How can I get all that existing data into Sencha.io?

jason.cline
10 Apr 2013, 7:57 AM
Hello,

Yes. You can create create users, groups and even apps using the APIs that are included in the SDK download. The management console actually uses the SDK itself to execute all of its actions.

Users can be created programmatically using the register method:
http://docs.sencha.io/current/index.html#!/api/Ext.io.User-static-method-register

At the moment you can only have a single authentication group per application but that authentication group can shared between applications so you may not need or want to create them programatically.

However you can do this via Sencha Cmd:



jason$ sencha io create-appSencha Cmd v3.1.0.256
[INF] Usage: sencha io create-app <appName> <username> <password> <teamName>
[INF] appName: the name of your application. Must be unique.
[INF] username: your Sencha.io username
[INF] password: your Sencha.io password
[INF] teamName: the Team name in which to create the app (optional)




jason$ sencha io create-auth-groupSencha Cmd v3.1.0.256
[INF] Usage: sencha io create-auth-group <groupName> <username> <password> <teamName>
[INF] groupName: the name for your new group
[INF] username: your Sencha.io username
[INF] password: your Sencha.io password
[INF] teamName: the team name to use <optional>


As for storing user data what kind of data are you attempting to store for each user?
There are two options for storing data:
1) via custom attributes on the user object itself

Once you have a user object you can call user.update({custom: someJson}) and the values will be stored on the server and readable by any other user in the application

2) as part of a sync store.

Define a Model and Store with a sync proxy

khooten
10 Apr 2013, 8:54 AM
Jason,

Thanks for the prompt reply. I guess I misunderstood how the data sharing and privacy worked. I need to share data among some users but not all users. Each company (my customer) will have several employees at that company that need to share and sync data. However, I need to make sure that other users of the app that do not work for that company cannot see their data.

I was planning to make one Group for each company so that everyone in that Group could see the data but noone else.

lalexgraham
21 May 2013, 4:33 AM
Jason, can you expand a little more on

2) as part of a sync store.

Define a Model and Store with a sync proxy

If we had a live database already but we wanted to manipulate that data through a sencha touch app how would we go about importing the data into Sencha.io and then refreshing the database at certain times in the day? It seems most examples of sencha.io assume you are starting without a database already.

Thanks