{"id":948,"url":"https://github.com/ml-archive/CoreDataDandy","last_synced_at":"2025-07-30T19:33:04.676Z","repository":{"id":56906652,"uuid":"50956962","full_name":"ml-archive/CoreDataDandy","owner":"ml-archive","description":"A feature-light wrapper around Core Data that simplifies common database operations. ","archived":true,"fork":false,"pushed_at":"2020-02-11T15:51:49.000Z","size":247,"stargazers_count":34,"open_issues_count":1,"forks_count":3,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-11-18T03:38:31.741Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ml-archive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-02T22:35:45.000Z","updated_at":"2024-07-28T07:56:55.000Z","dependencies_parsed_at":"2022-08-20T19:10:06.070Z","dependency_job_id":null,"html_url":"https://github.com/ml-archive/CoreDataDandy","commit_stats":null,"previous_names":["fuzz-productions/coredatadandy"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ml-archive%2FCoreDataDandy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ml-archive%2FCoreDataDandy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ml-archive%2FCoreDataDandy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ml-archive%2FCoreDataDandy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ml-archive","download_url":"https://codeload.github.com/ml-archive/CoreDataDandy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228179038,"owners_count":17881127,"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":[],"created_at":"2024-01-05T20:15:35.274Z","updated_at":"2024-12-04T19:32:25.931Z","avatar_url":"https://github.com/ml-archive.png","language":"Swift","funding_links":[],"categories":["Core Data"],"sub_categories":["Linter","Other free courses"],"readme":"![header](header.png)\n\n[![Build Status](https://travis-ci.org/fuzz-productions/CoreDataDandy.svg?branch=master)](https://travis-ci.org/fuzz-productions/CoreDataDandy)\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/fuzz-productions/CoreDataDandy)\n[![CocoaPods Compatible](https://img.shields.io/badge/pod-0.6.1-blue.svg)](https://cocoapods.org/pods/CoreDataDandy)\n[![GitHub license](https://img.shields.io/badge/license-MIT-lightgrey.svg)](https://github.com/fuzz-productions/CoreDataDandy/blob/master/LICENSE)\n\n## Introduction\nCore Data Dandy is a feature-light wrapper around Core Data that simplifies common database operations.\n\n## Feature summary\n\n* Initializes and maintains a Core Data stack.\n* Provides convenience methods for saves, inserts, fetches, and deletes.\n* Maps json into NSManagedObjects via a lightweight API.\n* Deserializes NSManagedObjects into json\n\n## Installation\n\n### Carthage\n\n```\ngithub \"fuzz-productions/CoreDataDandy\" ~\u003e 0.6.1\n```\n\n### CocoaPods\n\n```\npod 'CoreDataDandy', '0.6.1'\n```\n\n## Usage\n\nAll standard usage of Core Data Dandy should flow through CoreDataDandy's sharedDandy. More advanced users, however, may find its various components useful in isolation.\n\n### Bootstrapping\n```swift\nCoreDataDandy.wake(\"ModelName\")\n```\n\n### Saving and deleting\n\nSave with or without a closure.\n\n```swift\nDandy.save()\nDandy.save { error in\n\t// Respond to save completion.\n}\n```\n\nDelete with or without a closure.\n\n```swift\nDandy.delete(object)\nDandy.delete(object) {\n\t// Respond to deletion completion.\n}\n```\n\nDestroy the contents of the database. Called, for example, to recover from a failure to perform a migration.\n\n```swift\nDandy.tearDown()\n```\n\n### Fetching\n\nFetch all objects of a given type.\n\n```swift\nDandy.fetch(Gossip.self)\n```\n\nFetch an object corresponding to an entity and primaryKey value.\n\n```swift\nDandy.fetchUnique(Hat.self, identifiedBy: \"bowler\")\n```\n\nFetch an array of objects filtered by a predicate.\n\n```swift\nDandy.fetch(Gossip.self, filterBy: NSPredicate(format: \"topic == %@\", \"John Keats\"))\n```\n\n### Insertions and updates\n\nInsert object of a given type.\n\n```swift\nDandy.insert(Gossip.self)\n```\n\nInsert or fetch a unique a object from a primary key.\n\n```swift\nDandy.insertUnique(Slander.self, identifiedBy: \"WILDE\")\n```\n\nUpsert a unique object, or insert and update a non-unique object.\n\n```swift\nDandy.upsert(Gossip.self, from: json)\n```\n\nUpsert an array of unique objects, or insert and update non-unique objects.\n\n```swift\nDandy.batchUpsert(Gossip.self, from: json)\n```\n\n### Mapping finalization\n\nObjects requiring custom mapping finalization should adopt the `MappingFinalizer` protocol. The protocol has a single function, `finalizeMapping(_:)`.\n\n```swift\nextension Conclusion: MappingFinalizer {\n\tfunc finalizeMapping(of json: [String : AnyObject]) {\n\t\tif var content = content {\n\t\t\tcontent += \"_FINALIZED\"\n\t\t\tself.content = content\n\t\t}\n\t}\n}\n```\n\n### Serialization\n\nSerialize a single object.\n\n```swift\nSerializer.serialize(gossip)\n```\n\nSerialize an array of objects.\n\n```swift\nSerializer.serialize([byron, wilde, andre3000])\n```\n\nSerialize an object and its relationships.\n\n```swift\nSerializer.serialize(gossip, including: [\"purveyor\"])\n```\n\nSerialize an object and its nested relationships.\n\n```swift\nSerializer.serialize(gossip, including: [\"purveyor.hats.material, purveyor.predecessor\"])\n```\n\n## xcdatamodel decorations\n\nCoreDataDandy supports four xcdatamodel attributes. All decorations are declared and documented in DandyConstants.\n\n**@primaryKey**\n\nAdd this decoration to the entity's userInfo to specify which property on the entity functions as its primaryKey.\n\n**@mapping**\n\nAdd this decoration to a property to specify an alternate mapping for this property. For instance, if a property is named \"abbreviatedState,\" but the json value for this property is found at the key \"state,\" add @mapping : state to the abbreviatedState's userInfo.\n\n**@false**\n\nUse this decoration in conjunction with the @mapping keyword to disable mapping to the property. For instance, if your entity has an attribute named \"secret\" that you'd prefer to map yourself, add @mapping : @false to secret's userInfo.\n\n**@singleton**\n\nAdd this decoration to an entity's userInfo if there should never be more than one instance of this entity in your database. This decoration may be useful for objects like Tokens and CurrentUsers, though it's primarily included to suggest the kind of decorations that may be added in the future.\n\n## Warnings\n\nTo receive console warnings in Swift projects, add the entry -D DEBUG in your project's build settings under Swift Compiler - Custom Flags.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fml-archive%2FCoreDataDandy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fml-archive%2FCoreDataDandy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fml-archive%2FCoreDataDandy/lists"}