惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
Microsoft Azure Blog
Microsoft Azure Blog
V
V2EX
阮一峰的网络日志
阮一峰的网络日志
宝玉的分享
宝玉的分享
Hugging Face - Blog
Hugging Face - Blog
Y
Y Combinator Blog
Recorded Future
Recorded Future
博客园 - Franky
F
Fortinet All Blogs
The Register - Security
The Register - Security
雷峰网
雷峰网
博客园 - 【当耐特】
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
WordPress大学
WordPress大学
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Recent Announcements
Recent Announcements
S
Schneier on Security
Latest news
Latest news
S
Securelist
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Blog — PlanetScale
Blog — PlanetScale
L
Lohrmann on Cybersecurity
V
Visual Studio Blog
NISL@THU
NISL@THU
Cyberwarzone
Cyberwarzone
H
Hackread – Cybersecurity News, Data Breaches, AI and More
腾讯CDC
Spread Privacy
Spread Privacy
酷 壳 – CoolShell
酷 壳 – CoolShell
Security Latest
Security Latest
A
About on SuperTechFans
大猫的无限游戏
大猫的无限游戏
SecWiki News
SecWiki News
N
News and Events Feed by Topic
T
Threatpost
The GitHub Blog
The GitHub Blog
博客园_首页
F
Full Disclosure
爱范儿
爱范儿
The Hacker News
The Hacker News
T
The Blog of Author Tim Ferriss
Stack Overflow Blog
Stack Overflow Blog
Last Week in AI
Last Week in AI
月光博客
月光博客
C
Check Point Blog
G
Google Developers Blog
M
MIT News - Artificial intelligence
博客园 - 司徒正美

博客园 - 一根神棍研古今

实测:Windows 8.1 (Windows Blue) 第三方桌面应用无法支持Retina屏,效果与Windows8.0似无差别。 MAC OSX中游戏花屏或在VMWARE下开启3D发生花屏及贴图错误的解决 MAC OSX 中,删除右键菜单中的多余重复项。 Windows2003上使用IIS7 Express使用FastCgi运行php 对淘宝一些规则的一些研究分享 傅立叶变换最直白最容易理解最直接最真实最有深度的解释 四种聚类方法之比较 人工大脑项目 —— Nengo MAC PRO RETINA 下使用VMWARE以BOOTCAMP启动WIN8的性能下降一个档次 【转】千万不要在夏季开发苹果应用,否则后果很严重 IOS小技巧积累 2012年全球最愚蠢的设计第一是微软,第二还是微软 淘宝的服务器弱爆了,由此严重怀疑阿里云的稳定性 小红帽的故事居然是从法国民间的一个狼人诱奸小女孩的故事改来的 TAFFY Working with data TaffyDB Writing queries TaffyDB Beginner's Guide 作为资深程序员,必定会掌握的十句谎话 诺基亚推两款WP8新机,为何股价反而大跌15%
TaffyDB Introduction
一根神棍研古今 · 2012-10-22 · via 博客园 - 一根神棍研古今

The JavaScript Database

An opensouce library that brings database features into your JavaScript applications.

Introduction

How you ever noticed how JavaScript object literals look a lot like records? And that if you wrap a group of them up in an array you have something that looks a lot like a database table? TaffyDB is a libary to bring powerful database funtionality to that concept and rapidly improve the way you work with data inside of JavaScript.

What makes it sticky

  • Small file size, extremely fast queries
  • Powerful JavaScript centric data selection engine
  • Database inspired features such as count, update, and insert
  • Robust cross browser support
  • Easily extended with your own functions
  • Compatible with any DOM library (jQuery, YUI, Dojo, etc)
  • Compatible with Server Side JS

Create a Database

// Create DB and fill it with records
var friends = TAFFY([
	{"id":1,"gender":"M","first":"John","last":"Smith","city":"Seattle, WA","status":"Active"},
	{"id":2,"gender":"F","first":"Kelly","last":"Ruth","city":"Dallas, TX","status":"Active"},
	{"id":3,"gender":"M","first":"Jeff","last":"Stevenson","city":"Washington, D.C.","status":"Active"},
	{"id":4,"gender":"F","first":"Jennifer","last":"Gill","city":"Seattle, WA","status":"Active"}	
]);

Filter using the database name and object comparison

// Find all the friends in Seattle
friends({city:"Seattle, WA"});

// Find John Smith, by ID
friends({id:1});

// Find John Smith, by Name
friends({first:"John",last:"Smith"});

Access data easily

// Kelly's record
var kelly = friends({id:2}).first();

// Kelly's last name
var kellyslastname = kelly.last;

// Get an array of record ids
var cities = friends().select("id");

// Get an array of distinct cities
var cities = friends().distinct("city");

// Apply a function to all the male friends
friends({gender:"M"}).each(function (r) {
   alert(r.name + "!");
});

Modify data on the fly

// Move John Smith to Las Vegas
friends({first:"John",last:"Smith"}).update({city:"Las Vegas, NV:"});

// Remove Jennifer Gill as a friend
friends({id:4}).remove();

// insert a new friend
friends.insert({"id":5,"gender":"F","first":"Jennifer","last":"Gill","city":"Seattle, WA","status":"Active"});