Skip to content

aabluedragon/lovefield-dart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 

Repository files navigation

lovefield-dart

Lovefield interop for Dart

Keep in mind this is a work-in-progress, so even though basic functionality works (as the example below), more advanced features were not tested and might not yet function as expected.

Getting Started

import 'package:lovefield/lovefield.dart';

main() async {

  SchemaBuilder schemaBuilder = new SchemaBuilder('PersonsDatabase', 1);
  schemaBuilder.createTable('Person')
    .addColumn('id', ColumnType.INTEGER)
    .addColumn('age', ColumnType.INTEGER)
    .addColumn('name', ColumnType.STRING)
    .addPrimaryKey(['id'])
    .addIndex('idxAge', ['age'], false, Order.ASC);

  Database db = await schemaBuilder.connect();
  Table personTable = db.getSchema().table('Person');

  Row row = personTable.createRow({'id':1,'name':'Alon','age':26});
  await db.insert().into(personTable).values([row]).exec();

  List<dynamic> objs = await db.select().from1(personTable).where(
    and(
      personTable.v('age').eq(26),
      personTable.v('name').eq('Alon')
    )
  ).exec();

  print(objs.elementAt(0)['name']);

}

Guided by https://github.com/google/lovefield/blob/40bf6a63c67a40f3bd13196fc2ca7c53d0a33b54/dist/lovefield.d.ts

About

Lovefield interop for Dart

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages