Quantcast
Channel: Clarity Blogs » Javascript
Viewing all articles
Browse latest Browse all 12

Our Summer with Parse

$
0
0

Intro
We have been using Parse as the backend platform for a Web site and iOS app for a few months now and wanted to share some of our feedback (Pros, Cons, and Gotchas) on a few of the functional areas. My team’s primary focus of the project was the integration of the Website with Parse using the JavaScript SDK.

Data
Parse offers a noSQL database with a web-based UI, called the Data Browser, to support management of the classes and the associated data.
Each record by default is assigned the following fields: objectId (to serve as the row’s unique identifier), createdAt (to capture the date/time of initial creation), updatedAt (to capture the date/time of when the record was last updated), and ACL (to control the read/write permissions for that particular record).

Pros:
• Parse supports more complex data types such as GeoPoint (for storing the latitude and longitude of a particular location), Array, File (for file storage within Parse), Pointer (the typical Foreign Key relationship) and Relation (to store a one to many relationship).
• Parse can easily extract all of your data. You initiate a request in the Parse Dashboard and Parse emails you a zip file of JSON files – one file per table. I would usually then copy the content of the files into an online JSON viewer to visualize the data better, e.g. http://jsonviewer.stack.hu
Cons:
• The Data Browser only allows you to view one class at a time, although it does support easy navigation to other classes if there is a Pointer or Relation on the class. Coming from a SQL Server background I was used to writing queries in Management Studio and seeing multiple results in one window that were sorted by one or more specified columns. This particular project was not as complex as some of my past projects, so navigating between classes and noting the objectIds wasn’t too painful.
Gotchas:
• The ability to update values directly in the Parse Dashboard Data Browser is a blessing and a curse. It makes direct inserts and updates quick to execute without having to write query statements, but since changes are committed immediately there is no way to rollback. Use caution when updating a value, deleting a row, or deleting a column since it cannot be undone/rolled back.
• If an object is failing to save without an intuitive message, double check the Class Level Permissions for the object which is an Advanced setting under the Security option. This caught us once because even though the row-level permission was correct, the Write / Update permission at the class level was disabled for some reason and we were unable to update a record. The error message we recevied wasn’t too informative.
Security / Edit Class Level Permissions
Advanced Settings
Cloud Code
Parse supports running code in the Parse Cloud, which they host as Cloud Code. The Cloud function can be invoked from the client SDKs and through the REST API. Parse also supports integration with third parties via the Cloud Code. In our implementation we overwrote the beforeSave and afterSave methods for certain objects in order to take another action when a record was being inserted/updated. We also integrated with Stripe as a payment mechanism.

Pros:
• The Cloud Code is very easy to deploy to the server via a command line.
• The Parse Dashboard supports viewing the actual file contents of the deployed Cloud Code. Normally, tracking of build versions or files’ modified dates is the only way to infer what version of the code was running on the server. By seeing the actual code, you can confirm if functionality was actually deployed or if it somehow got missed.
• The integration with Stripe was easy to implement with the Cloud Code.
Cons:
• Logging functionality is present but not as robust as other implementations I have used on .NET projects such as log4net’s ability to log to a rolling file or database for better auditability and monitoring.
Gotchas:
• The beforeSave and afterSave methods were helpful when writing code to affect other tables. Occasionally there was a gotcha in that the original record that was being inserted/updated did not have permission to update a record in the other table due to ACL permissions. Luckily you can overwrite that restriction with the useMasterKey call which allows the code to execute under the master user account instead of the user initiating the request.
useMasterKey sample call

Config
Parse supports configuration values at the app level. In our implementation we used a handful of config values to manage variables that could change.

Pros:
• The Parse Dashboard has an interface which makes it easy to add and update configuration parameters. A config parameter can be any of Parse’s supported data types:
Config Parameter Types
• The config value is available by the system on the next read and is retrieved by a simple get() call.
Retrieving a config value
API Console
The API Console is a great built-in feature to allow you to easily test API calls. No real Pros/Cons come to mind, but just make sure you are using the correct action for what you are trying to execute.
API Console
Analytics
Parse provides a mechanism to monitor the real-time health of your system in a visual way. For our particular project we just grazed the surface of its capabilities by using the Parse.Analytics.track call to track client-side errors, but we will be looking into this more as our project moves to Production to analyze things such as API Requests, Slow Queries, etc.
Analytics example
Gotchas:
• The track method is expecting string values for the keys. In our case we were receiving numeric error codes and tried to pass them to the track method as-is in the array, but it was generating an error on the client-side which we noticed by having the Developer Tools / Console window open. To get around it we had to force the error.code value to a string first:
Analytics call
User Management
Parse automatically handles many of the capabilities necessary for user account management. Actions such as signing up, logging in, resetting a forgotten password, and even integration with Facebook are all built-in. With our implementation we added a requirement for a user’s password to be at least 6 characters via client-side validation.

Misc. Feature
Clone App – this feature was great to have when we started on Phase 2 but did not want to recreate the whole backend from scratch. We were able to clone our main environment to use as a base for our next version effortlessly.
Clone App
Summary
Overall we have enjoyed our summer developing with Parse and are looking forward to exploring even more what Parse has to offer. Functionality such as Background Jobs and more advanced Analytics are just a few of the areas we will be looking into for Phase 2. Check out their expansive Documentation on their site for more information.


Viewing all articles
Browse latest Browse all 12

Latest Images

Trending Articles





Latest Images