function put_api_cursor (req, res) { if (req.suffix.length !== 1) { actions.resultBad(req, res, arangodb.ERROR_HTTP_BAD_PARAMETER); return; } var cursorId = decodeURIComponent(req.suffix[0]); var cursor = CURSOR(cursorId); if (! (cursor instanceof arangodb.ArangoCursor)) { actions.resultBad(req, res, arangodb.ERROR_CURSOR_NOT_FOUND); return; } try { // note: this might dispose or persist the cursor actions.resultCursor(req, res, cursor, actions.HTTP_OK); } catch (e) { } // force garbage-collection cursor = null; internal.wait(0.0); }
function POST_api_cursor(req, res) { if (req.suffix.length != 0) { actions.resultNotFound(req, res, arangodb.ERROR_CURSOR_NOT_FOUND); return; } var json = actions.getJsonBody(req, res); if (json === undefined) { return; } var cursor; if (json.query != undefined) { cursor = QUERY(json.query, json.bindVars, (json.count != undefined ? json.count : false), json.batchSize, (json.batchSize == undefined)); } else { actions.resultBad(req, res, arangodb.ERROR_QUERY_EMPTY); return; } // error occurred if (cursor instanceof ArangoError) { actions.resultBad(req, res, cursor.errorNum, cursor.errorMessage); return; } // this might dispose or persist the cursor actions.resultCursor(req, res, cursor, actions.HTTP_CREATED, { countRequested: json.count ? true : false }); }
function post_graph_all_edges (req, res, g) { var json = actions.getJsonBody(req, res); if (json === undefined) { json = {}; } try { var data = { 'filter' : '', 'bindVars' : { '@edgeColl' : g._edges.name() } }; var limit = ""; if (json.limit !== undefined) { limit = " LIMIT " + parseInt(json.limit, 10); } if (json.filter !== undefined && json.filter.properties !== undefined) { process_properties_filter(data, json.filter.properties, "e"); } if (json.filter !== undefined && json.filter.labels !== undefined) { process_labels_filter(data, json.filter.labels, "e"); } var query = "FOR e IN @@edgeColl" + data.filter + limit + " RETURN e"; var options = { count: json.count, batchSize: json.batchSize || 1000 }; var cursor = AQL_EXECUTE(query, data.bindVars, options); // error occurred if (cursor instanceof Error) { actions.resultBad(req, res, cursor); return; } // this might dispose or persist the cursor actions.resultCursor(req, res, cursor, actions.HTTP_CREATED, { countRequested: json.count ? true : false }); } catch (err) { actions.resultBad(req, res, arangodb.ERROR_GRAPH_INVALID_VERTEX, err); } }
callback : function (req, res) { try { var body = actions.getJsonBody(req, res); if (body === undefined) { return; } if (req.requestType != actions.PUT) { actions.resultUnsupported(req, res); } else { var limit = body.limit; var skip = body.skip; var name = body.collection; var attribute = body.attribute; var left = body.left; var right = body.right; var closed = body.closed; var collection = db._collection(name); if (collection === null) { actions.collectionNotFound(req, res, name); } else { var result; if (closed) { result = collection.closedRange(attribute, left, right); } else { result = collection.range(attribute, left, right); } if (skip !== null && skip !== undefined) { result = result.skip(skip); } if (limit !== null && limit !== undefined) { result = result.limit(limit); } actions.resultCursor(req, res, CREATE_CURSOR(result.toArray(), true, body.batchSize)); } } } catch (err) { actions.resultException(req, res, err); } }
callback : function (req, res) { try { var body = actions.getJsonBody(req, res); if (body === undefined) { return; } if (req.requestType != actions.PUT) { actions.resultUnsupported(req, res); } else { var limit = body.limit; var skip = body.skip; var attribute = body.attribute; var query = body.query; var iid = body.index || undefined; var name = body.collection; var collection = db._collection(name); if (collection === null) { actions.collectionNotFound(req, res, name); } else if (attribute === null || attribute === undefined) { actions.badParameter(req, res, "attribute"); } else if (query === null || query === undefined) { actions.badParameter(req, res, "query"); } else { var result = collection.fulltext(attribute, query, iid); if (skip !== null && skip !== undefined) { result = result.skip(skip); } if (limit !== null && limit !== undefined) { result = result.limit(limit); } actions.resultCursor(req, res, CREATE_CURSOR(result.toArray(), true, body.batchSize)); } } } catch (err) { actions.resultException(req, res, err); } }
function post_api_cursor(req, res) { if (req.suffix.length !== 0) { actions.resultNotFound(req, res, arangodb.ERROR_CURSOR_NOT_FOUND); return; } var json = actions.getJsonBody(req, res); if (json === undefined) { actions.resultBad(req, res, arangodb.ERROR_QUERY_EMPTY); return; } var cursor; if (json.query !== undefined) { cursor = internal.AQL_QUERY(json.query, json.bindVars, { count : json.count || false, batchSize: json.batchSize || 1000, ttl: json.ttl }, json.options); } else { actions.resultBad(req, res, arangodb.ERROR_QUERY_EMPTY); return; } // error occurred if (cursor instanceof Error) { actions.resultException(req, res, cursor, undefined, false); return; } // this might dispose or persist the cursor actions.resultCursor(req, res, cursor, actions.HTTP_CREATED, { countRequested: json.count ? true : false }); }
callback : function (req, res) { try { var body = actions.getJsonBody(req, res); if (body === undefined) { return; } if (req.requestType != actions.PUT) { actions.resultUnsupported(req, res); } else { var limit = body.limit; var skip = body.skip; var example = body.example; var name = body.collection; var collection = db._collection(name); if (collection === null) { actions.collectionNotFound(req, res, name); } else if (typeof example !== "object") { actions.badParameter(req, res, "example"); } else { var result = collection.byExample(example); if (skip !== null && skip !== undefined) { result = result.skip(skip); } if (limit !== null && limit !== undefined) { result = result.limit(limit); } actions.resultCursor(req, res, CREATE_CURSOR(result.toArray(), true, body.batchSize)); } } } catch (err) { actions.resultException(req, res, err); } }
callback : function (req, res) { try { var body = actions.getJsonBody(req, res); if (body === undefined) { return; } if (req.requestType != actions.PUT) { actions.resultUnsupported(req, res); } else { var limit = body.limit; var skip = body.skip; var latitude = body.latitude; var longitude = body.longitude; var distance = body.distance; var radius = body.radius; var geo = body.geo; var name = body.collection; var collection = db._collection(name); if (collection === null) { actions.collectionNotFound(req, res, name); } else if (latitude === null || latitude === undefined) { actions.badParameter(req, res, "latitude"); } else if (longitude === null || longitude === undefined) { actions.badParameter(req, res, "longitude"); } else { var result; if (geo === null || geo === undefined) { result = collection.within(latitude, longitude, radius); } else { result = collection.geo({ id : geo }).within(latitude, longitude, radius); } if (skip !== null && skip !== undefined) { result = result.skip(skip); } if (limit !== null && limit !== undefined) { result = result.limit(limit); } if (distance !== null && distance !== undefined) { result = result.distance(distance); } actions.resultCursor(req, res, CREATE_CURSOR(result.toArray(), true, body.batchSize)); } } } catch (err) { actions.resultException(req, res, err); } }
function post_graph_vertex_vertices (req, res, g) { var json = actions.getJsonBody(req, res); if (json === undefined) { json = {}; } try { var v = vertex_by_request(req, g); var data = { 'filter' : '', 'bindVars' : { '@vertexColl' : g._vertices.name(), '@edgeColl' : g._edges.name(), 'id' : v._properties._id } }; var limit = ""; if (json.limit !== undefined) { limit = " LIMIT " + parseInt(json.limit, 10); } var direction = "any"; if (json.filter !== undefined && json.filter.direction !== undefined) { if (json.filter.direction === "in") { direction = "inbound"; } else if (json.filter.direction === "out") { direction = "outbound"; } } if (json.filter !== undefined && json.filter.properties !== undefined) { process_properties_filter(data, json.filter.properties, "n.edge"); } if (json.filter !== undefined && json.filter.labels !== undefined) { process_labels_filter(data, json.filter.labels, "n.edge"); } // build aql query var query = 'FOR n IN NEIGHBORS( @@vertexColl, @@edgeColl, @id, "' + direction + '", null, ' + '{ includeData: true }) ' + data.filter + limit + " RETURN n.vertex "; var options = { count: json.count, batchSize: json.batchSize || 1000 }; var cursor = AQL_EXECUTE(query, data.bindVars, options); // error occurred if (cursor instanceof Error) { actions.resultBad(req, res, cursor); return; } // this might dispose or persist the cursor actions.resultCursor(req, res, cursor, actions.HTTP_CREATED, { countRequested: json.count ? true : false }); } catch (err) { actions.resultBad(req, res, arangodb.ERROR_GRAPH_INVALID_VERTEX, err); } }