Git Product home page Git Product logo

lovefield's Introduction

Lovefield

Build Status NPM version Bower version

Lovefield is a relational database written in pure JavaScript. It provides SQL-like syntax and works cross-browser (currently supporting Chrome 37+, Firefox 31+, IE 11+, Edge, and Safari 10+).

Please visit our public forum for general Q&A, feedback, and discussions.

Quick Start

Frequently Asked Questions

Specification

Developer Setup

Design Documents

Lovefield is Day 98 of 100 days of Google Dev. This is a quick 7-minute video filmed in August 2015.

Live 30min overview presentation at JS.LA (February 2015): Watch on YouTube or Vimeo.

lovefield's People

Contributors

12wrigja avatar arthurhsu avatar artskydj avatar blickly avatar claushellsing avatar concavelenz avatar dlras2 avatar eatingw avatar freshp86 avatar gantrior avatar ifraixedes avatar jtlindsey avatar kkirsche avatar lauraharker avatar martinkretzschmar avatar mizchi avatar nreid260 avatar pborreli avatar prayagverma avatar shicks avatar sowmyasb avatar timeu avatar vrana avatar wombleton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lovefield's Issues

Race condition in gulp scripts

On Windows, gulp debug will fail multiple times citing some random errors. Same observed on Linux and Mac, though not as reproducible as Windows.

Suspecting that somewhere in the gulp script has race conditions so that directories are created midst directory existence check.

Do not force user to create schema object every time

Today we force the user to create schema object every time (either through SPAC or the schema builder). This part of code can be big in size especially when the user has many tables. Lovefield should be able to serialize the schema into persistent store and retrieve the schema from there.

Targetting IE browsers with polyfill

Thanks for an interesting library. I look forward to diving into it!

In case you are interested in utilizing the full power of the indexedDB spec and use compound and multiEntry indexes, you might have noticed that IE don't support it. Good news is that there is a brand new polyfill making IE to support it fully:

https://github.com/dfahlander/idb-iegap

I have also released an indexedDB wrapper library and I felt I needed this polyfill to be able to target a greater audience without limiting the to least common denominator.

Regards,
David

lovefield-directive?

First off, I would like to express a heart felt thank you for developing this much needed browser base SQL engine. It has been an unexpectedly agonizing experience just find a tool like this.

Right now, I am struggling with applying the code within an angular application. The current example has the code in the main body of the application, which is great for a simple demo; but not so for placing the code within a reusable service, controller, etc.

Not sure if this is the proper place for a request, but is there in the works of developing an angular directive for lovefield library?

Enforce primary key constraints in INSERT and UPDATE queries

Inserting a record that already exists should throw an error. Updating a record that does not exist should also throw an error.

According to the spec primary key constraint violation should be reported as a ConstraintError. Instead, an error is thrown from the corresponding AATree index, needs to be fixed.

gulp test task does not consider existing HTML files.

Most of the tests have no corresponding HTML file and therefore a file is generated on the fly. But this is also happening for tests that do have their own HTML file. As an example the following test is failing.

gulp debug // starts the test server
gulp test --target=harness/min_js/lovefield_min_test

Convert tools scripts to use native Map/Set

Some of our scripts (for example tools/scan_deps.js) are using plain JS objects as a map. We are (probably) also using arrays instead of sets in a few places. This is just a leftover from we were using node v11. Now that node v12 is required for building/testing Lovefield, we can update such scripts.

Not able to add Foreign Key

I am using the following code from the <> example to add a foreign key:

addForeignKey('fk_ActorId', 'actorId', 'Actor', 'id');

But I am getting following error :

Uncaught TypeError: Cannot read property 'split' of undefined : lovefield.js:10844

on the following code:

lf.schema.ForeignKeySpec = function(rawSpec, name) {
  var array = rawSpec.ref.split("."); //ERROR IS ON THIS LINE.
  if (2 != array.length) {
    throw new lf.Exception(540, name);
  }
  this.childColumn = rawSpec.local;
  this.parentTable = array[0];
  this.parentColumn = array[1];
  this.name = name;
  this.action = rawSpec.action;
  this.timing = rawSpec.timing;
};

Have you changed the way a foreign key is created? I cannot find documentation about it.

Spurious errors thrown when Lovefield is used with Browserify.

Hello. Still continue trying to use library in Chrome App. Now I get another problem, when trying to connect() to schema:

developer tools - chrome-extension cipdlhkjnhaejbgafpfhegddnhfimlhn index html 2015-05-11 23-23-32

Errors: "document.open() is not available in packaged apps." and "Uncaught Error: document.write() is not available in packaged apps."

Tools:

  • grunt v0.4.5
  • browserify v10.1.3
  • lovefield v2.0.50

Safari <8 support ?

I have read the docs and tried the demos at http://google.github.io/lovefield/
and indeed LoveField does NOT yet support Safari

Is there any chance of officially supporting Safari via a shim such as : IndexedDB Polyfill over WebSql or FaceBook's IndexedDB polyfil

Safari 7.1 theoretically supports IndexedDB according to CanIUse.com
Apple has officially stated at WWDC 2014 that Safari 8 and iOS 8 will have full support for IndexedDB.

If there won't be any official support then it would be timely for us to provide a patch with Safari support.

Subqueries

According to the docs it appears that subqueries are not even going to be on the roadmap in the future, is there a reason for this decision? Will there be some alternative but semantically similar way to achieve the same effect?

Lovefield as component

Current design for lovefield to be used by external customers is

<script src="bundle.js"></script> <script> //start using lovefield </script>

This will be problematic if this happened

<script src="something.js"></script> <script src="bundle.js"></script> <script> //lovefield init will conflict </script>

Implement multi-column index

Currently the cross-column indices are composed as strings, for example

id_name

this does not work well with numeric fields (e.g. integer, number, date) because of lexical sorting order e.g.

-1_1 > 10_1

need to change the design. Things to consider include (but not limited to)

B-tree with multilevel keys
Quad-tree
R*-tree
Grid File

Trying to use in Chrome App. Get error: "Uncaught TypeError: Cannot set property 'Error' of undefined"

Trying to use in Chrome App. Get error: "Uncaught TypeError: Cannot set property 'Error' of undefined".

Screenshot: http://take.ms/NKjho

Tools:

grunt v0.4.5
browserify v10.1.3
lovefield v2.0.50

Example of code:

'use strict';

import lf from 'lovefield';
import logger from '../../utils/logger.js.es6';

class IndexedStorageDB {
  constructor() {
    this.schemaBuilder = lf.schema.create('cloud-database', 1);
    this.schemaBuilder.createTable('accounts').
      addColumn('id', lf.Type.INTEGER).
      addColumn('type', lf.Type.STRING).
      addColumn('title', lf.Type.STRING).
      addColumn('provider_key', lf.Type.STRING).
      addColumn('provider_secret', lf.Type.STRING).
      addColumn('is_default', lf.Type.BOOLEAN).
      addPrimaryKey(['id']).
      addIndex('idxType', ['type'], false, lf.Order.ASC);
  }

  loadAccounts() {
    logger.debug('load accounts');
  }
}

export default IndexedStorageDB;

gulp build failure

Building... 34 of 93 tests/harness/min_js/lovefield_min_test.js

tests\harness\min_js\lovefield_min_test.js:109: ERROR - variable lf is undeclared
var schemaBuilder = lf.schema.create('apicheck', 1);
^

1 error(s), 0 warning(s)

sync with remote db

Any plans on integrating or even discussing best practices on integrating the browser db powered by lovefield with a remote database?

Optimize join ordering in N-table joins where N > 2

Join ordering is a pretty heavy concept in query optimization. The available approaches can get very involved and maybe outside the scope of Lovefield.

As an example of different levels of addressing the issue consider the case of a 3 vs 4 table join.
A 3 table join graph has always the same chain structure as A -> B-> C, where edges in this graph represent a join condition between (leftTable, rightTable). On the other hand, In a 4 table join case the graph can have different structure (chain, cycle, star, clique etc), and therefore optimizing such graphs is a harder problem.

Need to find the extend to which Lovefield should address the join ordering optimization issue. There are simplifications that can be made, for example considering left-deep only trees.

At the very least, for the 3table join case, there should be no unnecessary cross-product operations, which with our current approach is not guaranteed (depends on the order of the tables as supplied in the query).

Persist indices instead of re-calculating them on startup

Currently, upon initialization the "prefetcher" fetches all data from the DB into memory and reconstructs all the indices. An alternate more-scalable approach is to persist indices, such that reconstructing them on startup does not require bringing all data into memory.

Improve observer registry look up

It seems that we are doing a linear search on all observed queries to find which ones refer to a given table. We can probably optimize this by having a mapping from table to queryBuilders.

Publish NPM Module

If you'd like to see wider adoption of this, I'd very strongly recommend you figure out a way to make the bundle compiler as simple as:

npm install -g lovefield
lovefield my_schema.yml

Having to manually install dependencies and the location of the closure compiler just isn't how things are done in the wider web world. Additionally, there should be easy hooks for others to build ecosystem plugins for things like Grunt, Gulp, etc.

Not trying to sound grumpy, but I think Lovefield is a really cool project and I'd like to see it get all the adoption it can get! ๐Ÿ‘ป ๐Ÿ˜ธ

not-nullable constraint should imply not-undefinable too

Currently null and undefined are treated differently in the context of nullability constraint checking, see

if (goog.isNull(row.payload()[column.getName()])) {
. Treating both undefined and null as a constraint violation seems better, given that assigning undefined to a non-nullable column does not seem like a valid use case, and probably the result of a bug in the client's code.

Provide column alias

This should be legal

select(p.id.as('photoId'), a.id.as('albumId')).from(p, a).where(p.albumId.eq(a.id));

the projected results will be

[photoId, albumId]

instead of

[Photo.id, Album.id]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.