{"id":26845351,"url":"https://github.com/enthus1ast/nisane","last_synced_at":"2025-04-30T20:25:45.175Z","repository":{"id":44747222,"uuid":"451244911","full_name":"enthus1ast/nisane","owner":"enthus1ast","description":"a seq unpacker and mini orm","archived":false,"fork":false,"pushed_at":"2022-07-18T08:05:19.000Z","size":25,"stargazers_count":7,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-30T20:25:36.343Z","etag":null,"topics":["database","orm","sequence","unpack"],"latest_commit_sha":null,"homepage":"","language":"Nim","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/enthus1ast.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-23T22:17:11.000Z","updated_at":"2022-07-04T21:07:30.000Z","dependencies_parsed_at":"2022-09-23T11:51:44.619Z","dependency_job_id":null,"html_url":"https://github.com/enthus1ast/nisane","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enthus1ast%2Fnisane","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enthus1ast%2Fnisane/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enthus1ast%2Fnisane/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enthus1ast%2Fnisane/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/enthus1ast","download_url":"https://codeload.github.com/enthus1ast/nisane/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251776882,"owners_count":21642071,"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":["database","orm","sequence","unpack"],"created_at":"2025-03-30T19:35:52.922Z","updated_at":"2025-04-30T20:25:45.154Z","avatar_url":"https://github.com/enthus1ast.png","language":"Nim","funding_links":[],"categories":[],"sub_categories":[],"readme":"a seq unpacker and mini `orm`\n\n```nim\ntype Obj = object\n  aa: string\n  bb: int\n  cc: bool\nvar se = [\"1337\",\"somethingToSkip\", \"foo\", \"1\", \"true\"]\nvar id: int\nvar obj = Obj()\nse.to(id, nil, obj)\nassert obj.aa == \"foo\"\nassert obj.bb == 1\nassert obj.cc == true\n```\n\n\n```nim\nimport db_sqlite\n\ntype\n  Foo = object\n    first: string\n    second: string\n    third: float\n    forth: int\n  Foo2 = object\n    first: string\n    second: string\n    third: float\n    forth: int\n\nvar db = open(\":memory:\", \"\", \"\", \"\")\n\n# Easy to create tables based on types.\ndb.exec(sql ct(Foo)) # create tables based on the types\ndb.exec(sql ct(Foo2)) # create tables based on the types\n\n# Easy to insert, based on types.\nfor idx in 0..10:\n  db.exec(sql ci(Foo), $idx \u0026 \"first\", \"second\", \"13.37\", \"123\")\n  db.exec(sql ci(Foo2), $idx \u0026 \"fasdfwefew\", \"fwef32fwef3\", \"13.37\", \"123\")\n\n# Just write any sql, then unpack the types.\nfor row in db.getAllRows(sql\"select * from Foo, Foo2 where Foo.id = Foo2.id\"):\n  var foo: Foo = Foo()\n  var foo2: Foo2 = Foo2()\n  row.to(nil, foo, nil, foo2) # skip elements with nil (eg: table id's)\n  # ... use foo and foo2\n```\n\n\nUnpack custom types:\n```nim\nimport nisane, strutils\n\ntype\n  MyCustom = object\n    x: int\n    y: int\n  Obj = object\n    aa: MyCustom\n    bb: int\n    cc: bool\n\n# Define unpacker in the form of\n# toXXX to unpack your custom types.\nproc toMyCustom(str: string): MyCustom =\n  let parts = str.split(\":\")\n  result.x = parts[0].parseInt\n  result.y = parts[1].parseInt\n\nvar se = [\"1337\",\"somethingToSkip\", \"123:456\", \"1\", \"true\"]\nvar id: int\nvar obj = Obj()\nse.to(id, nil, obj)\nassert obj.aa.x == 123\nassert obj.aa.y == 456\nassert obj.bb == 1\nassert obj.cc == true\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenthus1ast%2Fnisane","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fenthus1ast%2Fnisane","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenthus1ast%2Fnisane/lists"}