Lovefield Typescript port and modernization.
The port attempts to maintain API compatibility as much as possible.
Documentation of how to use this library can be found here.
- Most of original Lovefield features (except Firebase and static schema).
- NEW: NodeJS support: NodeJS 10+ will be supported (with memory store only).
- Legacy browsers and technologies. Please assume ES6 throughout.
- As of Apr 2020, Chrome 60+, Firefox 60+, Safari 10+, Edge are supported.
- Currently only continuously tested on latest Chrome given resource shortage.
- Firebase is no longer supported.
- This project is not sponsored by Google and the developers do not have unlimited access for this project.
- Firebase API changed and legacy Lovefield code cannot be used.
- Static schema: it was designed for use with Closure compiler. Since the tool chain has moved to TypeScript, it makes no sense to support it.
- Lovefield-TS no longer ships minified JavaScript file. Instead, it provides:
- Clean CommonJS (
dist/lovefield.js), ES Module (dist/lovefield.esm.js), and UMD (dist/lovefield.umd.js) bundles. - TypeScript declaration files in
dist/.
- Clean CommonJS (
- Lovefield-TS no longer uses flags to do compile-time control. Instead, a
runtime options object will be used. The interface is defined in
lib/base/lovefield_options.ts. Users are supposed to define an object following that interface and set options via the new APIlf.options.set().- By default, an options object not providing error message explanations is
provided for better minify performance. If you wish to include detailed
error message in your package, use or copy
testing/debug_options.ts.
- By default, an options object not providing error message explanations is
provided for better minify performance. If you wish to include detailed
error message in your package, use or copy
-
All namespaces are flattened. For example:
lf.Orderis flattened toOrderlf.schema.DataStoreTypeis flattened toDataStoreType
Please note, in ES6 modules, we usually do
import * as lf from 'lovefield-ts'; const order = lf.Order.DESC;
In CommonJS module system used by Node.js, we usually do
const lf = require('lovefield-ts'); const order = lf.Order.DESC;
-
TypeScript users cannot refer column by name, use
.col()API.const item = db.getSchema().table('Item'); // Use .col() API to refer to column here. // TypeScript indexed property forces everything to be typed the same. // This is a language limit and not much Lovefield authors can do here. // // item['orderDate'] <== this will cause type errors // item.col('orderDate') <== this will give perfect type checking return db.select().from(item).orderBy(item.col('orderDate')).exec();
- API tester and performance benchmarks are implemented in ES6 and removed
dependencies on Closure Libraries completely. They can be found in
externaldirectory. Currently they are not part of the automated test process yet.
lib: Lovefield main library source code.testing: Facility code used for testing, including mock objects and schemas.tests: Tests for Lovefield main library.demo: Demo applications in JavaScript, TypeScript, and Node.js.docs: Documentation and guides.external: External tools, API testers, and performance benchmarks.scripts: Utility scripts for development and testing.out: Temporary directory used to store intermediate files from the toolchain.dist: Generated distribution files (CommonJS, ESM, UMD, and types).coverage: Code coverage reports generated during testing.