Aller au contenu
- Download and install the Google AppEngine Java SDK
- Download and RingoJS
- Create a new RingoJS web app with AppEngines support:
ringo-admin create -a yourappname
- copy
persistence.js
and persistence.store.appengine.js
into the application’s WEB-INF/modules
directory. - Copy
appengine-api-*.jar
from your AppEngine Java SDK (in the $APPENGINESDK/lib/user/
directory) into WEB-INF/lib
. - Edit
WEB-INF/app/actions.js
as follows:var {Response} = require('ringo/webapp/response'); var persistence = require('./persistence').persistence; var persistenceStore = require('./persistence.store.appengine'); 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'}); };
- Run the application:
dev_appserver.sh .
- Load http://localhost:8080 in your browser. Which will return a JSON string saying status: ok.
- Check that an entity has been created