Database Reference
In-Depth Information
Social Graph Model
This section explores the social graph model and a few of the operations that typically accompany it. In particular, this
section looks at the following:
The User Entity
Sign-up and login
Updating a user
Creating a relationship type through a user by following other users
Managing user content, such as displaying, adding, updating, and removing status updates
The sample graph database used for these examples is loaded with data, so you can immediately begin working
with representative data in each of the graph models. In the case of the social graph—and for other graph models, as well—
you will log in with the user ajordan . Going forward, please log in with ajordan to see each of the working examples.
Note
Sign Up
The HTML required for the user sign-up form is shown in Listing 10-16 and can be found in the {PROJECTROOT}/app/
views/home/index.mustache file.
Listing 10-16. HTML Snippet of Sign-Up Form
<form class="navbar-form navbar-left" action="/signup/add" role="form"
id="createaccountform" method="post">
<div class="form-group">
<input type="text" placeholder=
"Username" name="username" class="form-control">
</div>
<button type="submit" class="btn btn-success">Create Account</button> &nbsp;
</form>
Although the sample application creates a user without a password, I am certainly not suggesting or advocating
this approach for a production application. excluding the password property was done in order to create a simple sign-up
and login that helps keep the focus on the more salient aspects of the Neography library.
Note
Sign-Up Route
In the sign-up route, start by doing a lookup on the username passed in the request and see if it already exists in the
database using the get_user_by_user_name method found in the User service layer, as provided in Listing 10-17. If no
match is found, the username is passed on to the save_user method.
If no errors are returned during the save attempt, the request is redirected via redirect and a message is passed to
thank the user for signing up. Otherwise, the error message back to the home view informs the user of the problem.
 
 
Search WWH ::




Custom Search