好的,我正在创建一个RingoJS项目,并将其托管在Google App Engine上。现在,App Engine允许您使用java.io.FileInputStream从文件系统读取数据,但它不允许您使用java.io.FileOutputStream向文件系统写入数据。
我想存储的数据是博客帖子的简单标记。现在,我正在尝试学习如何使用App Engine提供的High Replication Datastore API来存储数据,但我仍然对如何做到这一点感到困惑。
如果我没有错,我需要做以下事情(在JavaScript中):
// Get the High Replication Datastore API
importPackage(com.google.appengine.api.datastore);
// Create a new datastore
var datastore = DatastoreServiceFactory.getDatastoreService();
// Save the blog post
var blogPost = new Entity("BlogPost", uid, author.getKey());
blogPost.setProperty("markdown", markdown);
datastore.put(blogPost);
// Create the key for the blog post
var key = KeyFactory.createKey("BlogPost", uid, author.getKey());
// Getting the entity
var blogPost = datastore.get(key);
// Reading the properties
var markdown = blogPost.getProperty("markdown");我做的是对的吗?有没有其他方法可以轻松地存储持久数据?我只需要读写数据。我不需要查询。
发布于 2011-12-12 01:49:02
是的,你所做的看起来很好。数据存储是App Engine的可扩展存储系统,因此它是像这样存储数据的最佳(或多或少唯一的)选择。
https://stackoverflow.com/questions/8464618
复制相似问题