{"id":16683900,"url":"https://github.com/meniny/sqlable","last_synced_at":"2025-05-14T20:32:36.241Z","repository":{"id":62455953,"uuid":"125480143","full_name":"Meniny/Sqlable","owner":"Meniny","description":"Swift ORM framework.","archived":false,"fork":false,"pushed_at":"2019-04-16T04:14:19.000Z","size":34,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-13T09:51:26.114Z","etag":null,"topics":["databse","orm","sqlite"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Meniny.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-16T07:32:05.000Z","updated_at":"2019-04-16T04:13:39.000Z","dependencies_parsed_at":"2022-11-02T00:15:14.162Z","dependency_job_id":null,"html_url":"https://github.com/Meniny/Sqlable","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Meniny%2FSqlable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Meniny%2FSqlable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Meniny%2FSqlable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Meniny%2FSqlable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Meniny","download_url":"https://codeload.github.com/Meniny/Sqlable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225310090,"owners_count":17454089,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["databse","orm","sqlite"],"created_at":"2024-10-12T14:27:12.779Z","updated_at":"2024-11-19T07:09:09.693Z","avatar_url":"https://github.com/Meniny.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003cp align=\"center\"\u003e\n  \u003c!-- \u003cimg src=\"./Assets/Sqlable.png\" alt=\"Sqlable\"\u003e --\u003e\n  \u003cbr/\u003e\u003ca href=\"https://cocoapods.org/pods/Sqlable\"\u003e\n  \u003cimg alt=\"Version\" src=\"https://img.shields.io/badge/version-1.1.0-brightgreen.svg\"\u003e\n  \u003cimg alt=\"Author\" src=\"https://img.shields.io/badge/author-Meniny-blue.svg\"\u003e\n  \u003cimg alt=\"Build Passing\" src=\"https://img.shields.io/badge/build-passing-brightgreen.svg\"\u003e\n  \u003cimg alt=\"Swift\" src=\"https://img.shields.io/badge/swift-5.0%2B-orange.svg\"\u003e\n  \u003cbr/\u003e\n  \u003cimg alt=\"Platforms\" src=\"https://img.shields.io/badge/platform-macOS%20%7C%20iOS%20%7C%20tvOS%20%7C%20watchOS-lightgrey.svg\"\u003e\n  \u003cimg alt=\"MIT\" src=\"https://img.shields.io/badge/license-MIT-blue.svg\"\u003e\n  \u003cbr/\u003e\n  \u003cimg alt=\"Cocoapods\" src=\"https://img.shields.io/badge/cocoapods-compatible-brightgreen.svg\"\u003e\n  \u003cimg alt=\"Carthage\" src=\"https://img.shields.io/badge/carthage-working%20on-red.svg\"\u003e\n  \u003cimg alt=\"SPM\" src=\"https://img.shields.io/badge/swift%20package%20manager-compatible-brightgreen.svg\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## 🏵 Introduction\n\n**Sqlable** is a tiny library for ORM written in Swift.\n\n## 📋 Requirements\n\n- iOS 8.0+\n- macOS 10.10+\n- tvOS 9.1+\n- watchOS 2.2+\n- Xcode 9.0+ with Swift 4.0+\n\n## 📲 Installation\n\n`Sqlable` is available on [CocoaPods](https://cocoapods.org):\n\n```ruby\nuse_frameworks!\npod 'Sqlable'\n```\n\n## ❤️ Contribution\n\nYou are welcome to fork and submit pull requests.\n\n## 🔖 License\n\n`Sqlable` is open-sourced software, licensed under the `MIT` license.\n\n## 💫 Usage\n\nFirst, create a model:\n\n```swift\nstruct User {\n  var name: String\n}\n```\n\nthen, extend the model to confirm `Sqlable` protocol:\n\n```swift\nextension User: Sqlable {\n\n}\n```\n\nand, we need to create the database columns:\n\n```swift\nextension User: Sqlable {\n    // create your columns:\n\n    static let id = SQLColumn(\"id\", .integer, PrimaryKey(autoincrement: true))\n    static let name = SQLColumn(\"name\", .text)\n    static var tableLayout: [SQLColumn] = [id, name]\n\n    // implement there two functions:\n\n    func valueForColumn(_ column: SQLColumn) -\u003e SQLValue? {\n        switch column {\n        case User.name:\n            return self.name\n        default:\n            return nil\n        }\n    }\n\n    init(row: SQLReadRow) throws {\n        name = try row.get(User.name)\n    }\n}\n```\n\nnow, get your database:\n\n```swift\nlet doc = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false)\nlet database = try SQLiteDatabase.init(filepath: doc.appendingPathComponent(\"User.db\").path)\n```\n\ncreate table if not exists:\n\n```swift\ntry database.create(table: User.self)\n```\n\ndo your work, let's `insert` for example:\n\n```swift\ntry user.insert(into: database)\n```\nquery:\n\n```swift\ntry User.query(in: database)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeniny%2Fsqlable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeniny%2Fsqlable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeniny%2Fsqlable/lists"}