Earlier quoted context omitted.
Can you unpack that question a little for me? As in, could you use a spahql selection as the path component of some request? I don't see why not, but the escaping will probably look a little ugly.
Given a url that returns JSON: www.example.com/data.json, one could append SparQL to select a subset www.example.com/data.json/user www.example.com/data.json/categories/* www.example.com/data.json/categories/0/products www.example.com/data.json//avatar
SpahQL - A query language for Javascript objects
21–30 of 37 posts
Re: SpahQL - A query language for Javascript objects
#22I wish developers would stop copying SQL. It's like making fancy new languages, and then adding libraries that help you emulate COBOL. SQL is not the first, the last, or the best query language ever created, it's just the best marketed. It's not even properly relational, it's based on a series of shell scripts on multics for crying out loud!
"I wish developers would stop copying SQL" This really doesn't look much like SQL to me - much more like an interesting variation on XPath... Why do you think it is a copy of SQL?
Re: SpahQL - A query language for Javascript objects
#23Earlier quoted context omitted.
Can you unpack that question a little for me? As in, could you use a spahql selection as the path component of some request? I don't see why not, but the escaping will probably look a little ugly.
Given a url that returns JSON: www.example.com/data.json, one could append SparQL to select a subset www.example.com/data.json/user www.example.com/data.json/categories/* www.example.com/data.json/categories/0/products www.example.com/data.json//avatar
Perhaps something like:
www.example.com/data.json?query=/userRe: SpahQL - A query language for Javascript objects
#24I wish developers would stop copying SQL. It's like making fancy new languages, and then adding libraries that help you emulate COBOL. SQL is not the first, the last, or the best query language ever created, it's just the best marketed. It's not even properly relational, it's based on a series of shell scripts on multics for crying out loud!
Please provide some substance to your post. What other options exist? What are some references you've used to work with those options?
Edit: I also want to add Datalog http://en.wikipedia.org/wiki/Datalog
and list comprehensions http://en.wikipedia.org/wiki/List_comprehensions
Re: SpahQL - A query language for Javascript objects
#25Earlier quoted context omitted.
Given a url that returns JSON: www.example.com/data.json, one could append SparQL to select a subset www.example.com/data.json/user www.example.com/data.json/categories/* www.example.com/data.json/categories/0/products www.example.com/data.json//avatar
The only small issue I can see with that is identifying where the path to the resource ends and where the query to applied to the JSON representation of the resource starts. Perhaps something like: www.example.com/data.json?query=/user
Re: SpahQL - A query language for Javascript objects
#26Earlier quoted context omitted.
The only small issue I can see with that is identifying where the path to the resource ends and where the query to applied to the JSON representation of the resource starts. Perhaps something like: www.example.com/data.json?query=/user
A webserver could easily figure that out, as long as it is configured correctly and with knowledge of the domain. I don't like using query strings like this, as it makes the URL point to multiple objects.
www.example.com/foo
and it can arbitary sub-resources e.g. www.example.com/foo/bar/raz
then how do I know whether bar is a different resource or part of the JSON returned describing www.example.com/fooThis would mean you'd have to restrict your resource names to ensure they don't clash with JSON names - which seems a pain (e.g. say the resource names are uploaded files and directories, so you won't have much control over what they are called)
Re: SpahQL - A query language for Javascript objects
#27Earlier quoted context omitted.
The only small issue I can see with that is identifying where the path to the resource ends and where the query to applied to the JSON representation of the resource starts. Perhaps something like: www.example.com/data.json?query=/user
A webserver could easily figure that out, as long as it is configured correctly and with knowledge of the domain. I don't like using query strings like this, as it makes the URL point to multiple objects.
Re: SpahQL - A query language for Javascript objects
#28 Features
--------------------------------------
implement all .NET 4.0 methods and many extra methods
(inspiration from Rx, Achiral, Haskell, Ruby, etc...)
complete lazy evaluation
full IntelliSense support for VisualStudio
two versions - linq.js and jquery.linq.js (jQuery plugin)
support Windows Script Host
binding for Reactive Extensions for JavaScript(RxJS) and
IntelliSense Generator -> see documentation
NuGet install support(linq.js, linq.js-jQuery, linq.js-Bindings)
90 Methods
----------------------------------------
Aggregate, All, Alternate, Any, Average, BufferWithCount,
CascadeBreadthFirst, CascadeDepthFirst, Catch, Choice,
Concat,Contains, Count, Cycle, DefaultIfEmpty, Distinct, Do,
ElementAt, ElementAtOrDefault, Empty, Except, Finally, First,
FirstOrDefault, Flatten, ForEach, Force, From, Generate,
GetEnumerator, GroupBy, GroupJoin, IndexOf, Insert, Intersect,
Join, Last, LastIndexOf,
LastOrDefault, Let, Matches, Max, MaxBy, MemoizeAll, Min,
MinBy, OfType, OrderBy, OrderByDescending, Pairwise,
PartitionBy, Range, RangeDown, RangeTo, Repeat,
RepeatWithFinalize, Return, Reverse, Scan, Select, SelectMany,
SequenceEqual, Share, Shuffle,
Single, SingleOrDefault, Skip, SkipWhile, Sum, Take,
TakeExceptLast, TakeFromLast, TakeWhile, ThenBy,
ThenByDescending, ToArray,
ToDictionary, ToInfinity,ToJSON, ToLookup, ToNegativeInfinity,
ToObject, ToString, Trace, Unfold, Union, Where, Write,
WriteLine, ZipRe: SpahQL - A query language for Javascript objects
#29linq.js has been doing this for years now. Its a mature library, flexible and light. I use it for every web project, wouldn't know what to do with out it. http://linqjs.codeplex.com/ Examples: http://neue.cc/reference.htm Features -------------------------------------- implement all .NET 4.0 methods and many extra methods (inspiration from Rx, Achiral, Haskell, Ruby, etc...) complete lazy evaluation full IntelliSense…
* Declarative syntax for selections, such that selection queries may be handed between implementations in other languages
* Imperative syntax for updates, such that updates may be idiomatic to the language in which the spahql library has been ported (linq meets this criteria)
In essence all SpahQL is, is a shorthand syntax for generating traversal and descent functions, which output a proxy object for reading to and writing from the selected nodes.