TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

SpahQL - A query language for Javascript objects

83 点作者 raystar大约 13 年前

13 条评论

pygy_大约 13 年前
Interresting.<p>SQlike is another effort in the same direction. It provides a wide range of SQL features including joins. JavaScript tables are used as query language.<p>See <a href="http://www.thomasfrank.se/sqlike.html" rel="nofollow">http://www.thomasfrank.se/sqlike.html</a> for an overview and <a href="http://www.thomasfrank.se/SQLike/" rel="nofollow">http://www.thomasfrank.se/SQLike/</a> for examples.<p><pre><code> dataArray = [ {firstName: "Paul", lastName: "Stele", age:35, salary:35000}, ... ] dataArray2 = [ {firstName: "Paul", lastName: "Stele", favColor:"green"}, ... ] SQLike.q( { Select: ['*'], From: dataArray, Where: function(){return this.salary&#62;50000}, OrderBy: ['salary','|desc|'] } ) SQLike.q( { Select: ['*'], From: {t1:dataArray}, NaturalJoin: {t2:dataArray2}, Where:function(){return this.t1.firstName!='Vicki'} } )</code></pre>
评论 #4001968 未加载
DonnyV大约 13 年前
linq.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. <a href="http://linqjs.codeplex.com/" rel="nofollow">http://linqjs.codeplex.com/</a> Examples: <a href="http://neue.cc/reference.htm" rel="nofollow">http://neue.cc/reference.htm</a><p><pre><code> 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 -&#62; 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, Zip</code></pre>
评论 #4002763 未加载
marianoguerra大约 13 年前
have you considered adopting the jsonpath syntax?<p>it would be more javascripty and would be another implementation (or a superset) of jsonpath<p><a href="http://goessner.net/articles/JsonPath/" rel="nofollow">http://goessner.net/articles/JsonPath/</a> <a href="http://code.google.com/p/jsonpath/" rel="nofollow">http://code.google.com/p/jsonpath/</a> <a href="https://github.com/joshbuddy/jsonpath" rel="nofollow">https://github.com/joshbuddy/jsonpath</a> <a href="https://github.com/marianoguerra/jsonpath-scala" rel="nofollow">https://github.com/marianoguerra/jsonpath-scala</a>
评论 #4001960 未加载
ZenPsycho大约 13 年前
I 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!
评论 #4002202 未加载
评论 #4002190 未加载
评论 #4002182 未加载
Nemmie大约 13 年前
I have used linq.js in the past to query my JSON: <a href="http://linqjs.codeplex.com/" rel="nofollow">http://linqjs.codeplex.com/</a>
dagw大约 13 年前
Cool. This plus xml2js should make the whole process of extracting data from a bunch of 3rd-party xml files I'm currently dealing with a lot easier.
评论 #4002129 未加载
quile大约 13 年前
Nice.<p>Along these lines, by the way, is my Javascript port of Apple's "key-value coding":<p><a href="http://quile.github.com/keyvaluecoding-js" rel="nofollow">http://quile.github.com/keyvaluecoding-js</a><p>which allows you to traverse object graphs without all the null-check nonsense. Admittedly the purpose is slightly different, but they seem related.
46Bit大约 13 年前
Looks far too similarly pronounced to SPARQL (<a href="http://www.w3.org/TR/rdf-sparql-query/" rel="nofollow">http://www.w3.org/TR/rdf-sparql-query/</a>). Or is that deliberate?
评论 #4002266 未加载
willlll大约 13 年前
Also check out json:select <a href="http://jsonselect.org/#overview" rel="nofollow">http://jsonselect.org/#overview</a> It's more like css selectors than xpath
alexchamberlain大约 13 年前
This looks interesting, I wonder whether the path syntax would work in URLs.
评论 #4002189 未加载
mratzloff大约 13 年前
So, what does performance look like for complex data sets? Any benchmarks?
评论 #4003193 未加载
zdwalter大约 13 年前
shall we add SpahQL to MongoDB?
NHQ大约 13 年前
bookmarking this.