How to store data on app engine

Datastore Entity is the fundamental unit of data storage on Google App Engine.

cloudCMS has custom set of Freemarker directives to perform Google App Engine's datastore operation. One of the directive is to store data for Entity/Kind (a Table in terms of Database) to datastore.
It also gives you ability to create any Entity on demand and populate with HTML Form data.

<@storeEntity> Directive syntax

Adding a new row :

<@storeEntity kind="<EntityName>" <column1-name>=<value1> <columnN-name>=<valueN> />

For example, 
<@storeEntity kind="myGuestBook" guestName=wbrequest.guestName guestMessage=wbrequest.guestMsg />

In above example, it will create a row for Entity "myGuestBook" with 2 columns guestName and guestMessage. The value for column is read from HTML request object(wbrequest). Above syntax will create entity myGuestBook along with data if it does not exist in datastore.

Updating a row using Key's ID:
<@storeEntity kind="<EntityName>" id=<long-id> <column1-name>=<value1> <columnN-name>=<valueN> />
Updating a row using Key's WebSafe String version :
<@storeEntity kind="<EntityName>" key="<KeyAsString>" <column1-name>=<value1> <columnN-name>=<valueN> />

Note: For updating a entity row, its LongID or KeyAsString, only one of them is required.

Creating a child Entity


<@storeEntity kind="<EntityName>" parentKind="<parentEntityName>" 
<parentID|parentKey=LongID|keyAsString> <column1-name>=<value1> <columnN-name>=<valueN> />

Note: For parent Entity, its parentID or parentKey, only one of them is required.

blog comments powered by Disqus

Last Modified : Jul 9, 2009 3:30:12 PM