Yet Another Google App Engine Datastore ORM with a twist! (We need your support, fork it, and try it)
__ __ __
| |_.--.--.--|__.-----| |_
| _| | | | |__ --| _|
|____|________|__|_____|____|
:: Twist :: Object Mapping ::
twists aims to provide a lightweight Object mapping framework. Without adding complexity into the api.
Persisting POJO's, Maps and (soon Primitive types) directly into the datastore.
###Setup
@Inject
ObjectStore store;
Friend friend = createComplexFriend();
Key key = store.put(friend);
Friend saved = store.get(Friend.class, friend.getId());
Iterator<Friend> all = store.find(Friend.class).greaterThanOrEqual("name", "Joe").now();
Friend one = store.findOne(Friend.class).greaterThanOrEqual("name", "Joe").now();
###Updating
####Save
Passing an object to the put(..) method will do the job.
Friend joe = new Friend("Joe", 27);
store.put(joe);
joe.age = 28;
store.put(joe);
####Update
store.update(Friend.class).equals("name", "Joe").increment("age",1).now();
store.update(Friend.class).equals("name", "Joe").set("address", new Address(...)).now();
store.update(Friend.class).equals("name", "Joe").with(new Friend(..)).now();
####Insert
store.put(new Friend(..));
store.put(new Friend(..), new Friend(..));
####Remove
store.delete(key);
store.delete(friend.getId());
###Object Mapping
@Entity(name="CloseFriends") // Optional name
public class Friend {
@Id
private long id; // Can be long, Long or String only
@Parent
private Circle circle;
@Child
private Box box;
@Embedded
private Map map;
private List<String> notes;
}
###Querying
###Find & FindOne
Iterator<Friend> all = store.find(Friend.class).greaterThanOrEqual("name", "Joe").now();
Friend one = store.findOne(Friend.class).greaterThanOrEqual("name", "Joe").now();
####Projection and Field selection
store.find(Friend.class).projection("firstName", "address").greaterThanOrEqual("name", "Joe").now();
####Sorting
store.find(Friend.class).sortAscending("firstName").now();
store.find(Friend.class).sortDescending("lastName").now();
####Skip and Limit
store.find(Friend.class).skip(20).now();
store.find(Friend.class).limit(10).now();
0.0.1
twist uses a number of open source projects to work properly:
- [GAE SDK] - SDK for the AppEngine platform (GAE, AppScale or CapeDwarf)
- boon
mvn clean install
or add this to your POM:
<repositories>
<!-- Snapshot repository -->
<repository>
<id>oss-jfrog-artifactory-snapshots</id>
<name>oss-jfrog-artifactory-snapshots</name>
<url>http://oss.jfrog.org/artifactory/oss-snapshot-local</url>
</repository>
</repositories>
<dependency>
<groupId>com.textquo</groupId>
<artifactId>twist</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
- Anyone is welcome to contribute, implement feature or fix bugs.
Apache License, Version 2.0