Last active
August 29, 2015 14:01
-
-
Save gunnarmorling/c4a4826b6e7c11615a72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public Iterator<Tuple> executeBackendQuery(CustomQuery customQuery, QueryParameters queryParameters, EntityKeyMetadata[] metadatas) { | |
//e.g. "db.Item.find({ foo : bar }) | |
String query = customQuery.getSQL(); | |
// parse via Parboiled | |
QueryDescriptor qd = new QueryParser().parse( query ); | |
//qd.collection = "Item" | |
//qd.payload = "{ foo : bar }" | |
//qd.operation = Ops.FIND | |
DBCollection collection = provider.getDatabase().getCollection( qd.getCollection() ); | |
if ( qd.getOperation == Ops.FIND ) { | |
DBObject queryObj = JSON.parse( qd.getPayload() ); | |
DBObject proj = JSON.parse( qd.getProjection() ); | |
DBCursor cursor = collection.find( queryObj, proj ); | |
} | |
// in case of executeUpdate() | |
else if ( qd.getOperation() = Ops.INSERT ) { | |
collection.insert( qd.getQuery() ); | |
} | |
else if () { | |
... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment