Sqler Documentation Guide

Welcome to the Finch Sqler Documentation Guide! This guide will walk you through the steps to use Sqler in your Finch application. Whether you're a seasoned developer or just starting, Finch offers a robust set of tools to simplify server-side web app development.

What is Sqler?

Sqler is a query builder for SQL. It is used to build SQL queries in a more readable and maintainable way. It is used in Finch to build queries for MySQL and SQLite.

Using Sqler

Sqler is very easy to use. You can create a new instance of Sqler and start building your query. its a package that is not part of Finch, but it is used in Finch to build queries for MySQL and SQLite. you can find the documentation for Sqler here.

example

import 'package:sqler/sqler.dart';

void main() {
  // Create Table
  var books = MTable(
    name: 'books',
    fields: [
      MFieldInt(name: 'id', isPrimaryKey: true, isAutoIncrement: true),
      MFieldVarchar(name: 'name', length: 255),
      MFieldVarchar(name: 'author', length: 255),
      MFieldInt(name: 'publication_year'),
      MFieldDate(name: 'published_date'),
      MFieldText(name: 'content'),
    ],
  );

  // Simple SELECT query
  var query = Sqler()
    .addSelect(QSelect('name'))
    .addSelect(QSelect('published_date'))
    .from(QField('books'))
    .where(WhereOne(QField('publication_year'), QO.EQ, QVar(1980)))
    .orderBy(QOrder('name'))
    .limit(10);

  /// Print for MySQL:
  print(query.toSQL());

  /// Print for SQLite:
  print(query.toSQL<Sqlite>());
}