Skip to content

Releases: 0xLeif/FLite

1.1.0

24 Aug 00:52
67409fe
Compare
Choose a tag to compare

FLite

FLite is a streamlined Swift ORM for using FluentSQLiteDriver on iOS, macOS, watchOS, and tvOS applications.

What is FLite?

FLite is a Swift library that simplifies usage of FluentSQLiteDriver across various Apple platforms. It takes full advantage of Swift's strong type system and modern concurrency features to provide an easy-to-use interface for database management.

Features

  • Powered by FluentSQLiteDriver.
  • Simplified access to in-memory and SQLite database functionality.
  • Clean and intuitive APIs for database operations.
  • Non-blocking asynchronous methods that align with Swift's concurrency model for optimal performance.
  • Comprehensive support for database schema migrations.
  • Type-safe approach for building and executing database queries.

Installation

Swift Package Manager (SPM)

Add the following line to your Package.swift file in the dependencies array:

dependencies: [
    .package(url: "https://github.com/0xLeif/FLite.git", from: "1.0.0")
]

Usage

Firstly, be sure to import FLite in your file:

import FLite

Basic Usage

// Use FLite's shared memory singleton as our FLite database
let flite = FLite.memory

// Prepare a migration for a Todo model
try await flite.prepare(migration: Todo.self)

// Save a model instance to the database
try await flite.save(model: Todo(title: "Hello World", strings: ["hello", "world"]))

// Fetch all instances of our model
let todos = try await flite.all(model: Todo.self)
print(todos)

File Storage

let documentDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first?.path ?? ""
let fileURL = documentDirectory + "/default.sqlite"

let flite = FLite(configuration: .file(fileURL), loggerLabel: "Custom.FLite")

Batch Operations

let batchSize: UInt = 3

let todos = (0..<100).map { Todo(title: "Todo #\($0)", strings: []) }
try await flite.save(models: todos, batchSize: batchSize)

let allTodos = try await flite.all(model: Todo.self)
print("Saved \(allTodos.count) todos")

try await flite.deleteAll(model: Todo.self, batchSize: batchSize)

What's Changed

Full Changelog: 1.0.0...1.1.0

1.0.0

11 Aug 18:01
46401e1
Compare
Choose a tag to compare

FLite

FLite is a streamlined Swift ORM for using FluentSQLiteDriver on iOS, macOS, watchOS, and tvOS applications.

What is FLite?

FLite is a Swift library that simplifies usage of FluentSQLiteDriver across various Apple platforms. It takes full advantage of Swift's strong type system and modern concurrency features to provide an easy-to-use interface for database management.

Features

  • Powered by FluentSQLiteDriver.
  • Simplified access to in-memory and SQLite database functionality.
  • Clean and intuitive APIs for database operations.
  • Non-blocking asynchronous methods that align with Swift's concurrency model for optimal performance.
  • Comprehensive support for database schema migrations.
  • Type-safe approach for building and executing database queries.

Installation

Swift Package Manager (SPM)

Add the following line to your Package.swift file in the dependencies array:

dependencies: [
    .package(url: "https://github.com/0xLeif/FLite.git", from: "1.0.0")
]

Usage

Firstly, be sure to import FLite in your file:

import FLite

Basic Usage

// Use FLite's shared memory singleton as our FLite database
let flite = FLite.memory

// Prepare a migration for a Todo model
try await flite.prepare(migration: Todo.self)

// Add a model instance to the database
try await flite.add(model: Todo(title: "Hello World", strings: ["hello", "world"]))

// Fetch all instances of our model
let todos = try await flite.all(model: Todo.self)
print(todos)

File Storage

let documentDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first?.path ?? ""
let fileURL = documentDirectory + "/default.sqlite"

let flite = FLite(configuration: .file(fileURL), loggerLabel: "Custom.FLite")

Batch Operations

let batchSize: UInt = 3

let todos = (0..<100).map { Todo(title: "Todo #\($0)", strings: []) }
try await flite.add(models: todos, batchSize: batchSize)

let allTodos = try await flite.all(model: Todo.self)
print("Added \(allTodos.count) todos")

try await flite.deleteAll(model: Todo.self, batchSize: batchSize)

Contributing

FLite encourages community involvement and welcomes pull requests from experienced and first-time contributors. For bugs and feature requests, please create an issue.

License

FLite is released under the MIT License. See LICENSE for details.


Full Changelog: https://github.com/0xLeif/FLite/commits/1.0.0