Click here to Skip to main content
15,893,588 members
Articles / Web Development

RaptorDB REST

Rate me:
Please Sign up or sign in to vote.
4.92/5 (11 votes)
5 Dec 2013CPOL10 min read 36.1K   1K   29  
A REST web interface for RaptorDB the document database
<html>
<body> 
  <input id="jsonurl" type="text" value="http://localhost:8080/crm/salesitemrows?count=10" style="width:500"></input>	
  <button id="json">get json</button>
  <br/>
  <input id="funcurl" type="text" value="http://localhost:8080/testing/function" style="width:500"></input>	
  <button id="func">get function</button>
  <br/>
  <input id="viewsurl" type="text" value="http://localhost:8080/RaptorDB/GetViews" style="width:500"></input>
  <button id="views">get views</button>
  <br/>
  <input id="routesurl" type="text" value="http://localhost:8080/RaptorDB/GetRoutes" style="width:500"></input>
  <button id="routes">get routes</button>
  <br/>
  <input id="schemaurl" type="text" value="http://localhost:8080/RaptorDB/GetSchema?view=SalesItemRows" style="width:500"></input>
  <button id="schema">get schema</button>
  <br/>
	<pre id="pre"></pre>
	<script src="zepto.min.js"></script>
	<style>
	#results{
		border: 3px solid gray;
	}
	#results td{
		border: 1px solid gray;
	}
	</style>
    <script type="text/javascript">
	var d = null;
	function doit(url) {
		var startTime = new Date().getTime();
		$('#results').remove();
		$.getJSON( url,
			function (data) {
				$table = "<table id = 'results' >";
				for (var i = 0; i < data.Rows.length; i++)
				{  
					var it = data.Rows[i];
					if(i==0)
						for(var p in it)
							$table += "<th>" + p + "</th>";       
					$table += "<tr>";
					for(var p in it)
						$table += "<td>" + it[p] + "</td>";
					$table += "</tr>";
				}
				$table += "</table>";
				$('body').append($table);
				var endTime = new Date().getTime();
				$("#pre").text(
					"Total Count = " + data.TotalCount + 
					", Count = " + data.Count + 
					", time (+render) = " + (endTime - startTime) + " ms");
			});
	}
	$(document).ready(
		function () {
			$('#json').click( function() {doit($('#jsonurl').val())} );
			$('#views').click( function() {doit($('#viewsurl').val())} );
			$('#routes').click( function() {doit($('#routesurl').val())} );
			$('#schema').click( function() {doit($('#schemaurl').val())});
			$('#func').click( function() {doit($('#funcurl').val())});
		});
    </script>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect -
United Kingdom United Kingdom
Mehdi first started programming when he was 8 on BBC+128k machine in 6512 processor language, after various hardware and software changes he eventually came across .net and c# which he has been using since v1.0.
He is formally educated as a system analyst Industrial engineer, but his programming passion continues.

* Mehdi is the 5th person to get 6 out of 7 Platinum's on Code-Project (13th Jan'12)
* Mehdi is the 3rd person to get 7 out of 7 Platinum's on Code-Project (26th Aug'16)

Comments and Discussions