AppEngine Datastore Setup

  1. Download and install the Google AppEngine Java SDK
  2. Download and RingoJS
  3. Create a new RingoJS web app with AppEngines support:ringo-admin create -a yourappname
  4. copy persistence.js and into the application’s WEB-INF/modules directory.
  5. Copy appengine-api-*.jar from your AppEngine Java SDK (in the $APPENGINESDK/lib/user/ directory) into WEB-INF/lib.
  6. Edit WEB-INF/app/actions.js as follows:var {Response} = require('ringo/webapp/response'); var persistence = require('./persistence').persistence; var persistenceStore = require('./'); persistenceStore.config(persistence); var User = persistence.define("User", { username: "TEXT", password: "TExT" }); exports.index = function (req) { var session = persistenceStore.getSession(); var user = new User(session, {username: 'zef'}); session.add(user); session.flush(function() { // ... }) return Response.json({status: 'ok'}); };
  7. Run the .
  8. Load http://localhost:8080 in your browser. Which will return a JSON string saying status: ok.
  9. Check that an entity has been created

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *