{"id":20971994,"url":"https://github.com/kamva/octopus","last_synced_at":"2025-05-14T11:34:01.372Z","repository":{"id":57501509,"uuid":"157171669","full_name":"Kamva/octopus","owner":"Kamva","description":"Octopus is an ORM/ODM written in Go","archived":false,"fork":false,"pushed_at":"2019-09-07T14:25:22.000Z","size":115,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-02T17:51:21.276Z","etag":null,"topics":["golang","mongodb","mssql","octopus","orm","postgresql","sqlserver"],"latest_commit_sha":null,"homepage":"http://kamva.ir","language":"Go","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/Kamva.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":"2018-11-12T07:15:21.000Z","updated_at":"2022-09-06T15:40:14.000Z","dependencies_parsed_at":"2022-09-19T08:50:14.271Z","dependency_job_id":null,"html_url":"https://github.com/Kamva/octopus","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kamva%2Foctopus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kamva%2Foctopus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kamva%2Foctopus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kamva%2Foctopus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kamva","download_url":"https://codeload.github.com/Kamva/octopus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254131948,"owners_count":22020052,"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":["golang","mongodb","mssql","octopus","orm","postgresql","sqlserver"],"created_at":"2024-11-19T04:06:14.032Z","updated_at":"2025-05-14T11:34:01.360Z","avatar_url":"https://github.com/Kamva.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Octopus\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/Kamva/octopus)](https://goreportcard.com/report/github.com/Kamva/octopus)\n[![Build Status](https://travis-ci.org/Kamva/octopus.svg?branch=master)](https://travis-ci.org/Kamva/octopus)\n[![codecov](https://codecov.io/gh/Kamva/octopus/branch/master/graph/badge.svg)](https://codecov.io/gh/Kamva/octopus)\n\nOctopus is an ORM/ODM written in Golang. It supports SQL and NoSQL databases and is easy to use.\n\n## Get Started\n\nRun the following command to get octopus package\n\n```\ngo get -u -t github.com/Kamva/octopus\n```\n\n## Usage\n\nFor using octopus you need a scheme and a model. Scheme represent the field in your desired table (or collection),\nand Model is the struct that interact with the database.\n\nNote that the scheme must implement `octopus/base.Scheme` interface. The model struct must embed the `octopus.Model`\nand run `Initiate` method on its constructor.\n\n```go\npackage models\n\nimport (\n    \"github.com/Kamva/octopus\"\n    \"github.com/Kamva/octopus/base\"\n)\n\n\ntype User struct {\n    // This is optional. This only adds `GetKeyName` method implementation that\n    // returns `id` by default. for MongoDB you should use `octopus.MongoScheme`\n    // or implemet `GetKeyName` method yourself, as default primary key in Mongo\n    // is `_id`.\n    octopus.Scheme\n    ID          int     `sql:\"pk\"`\n    Name        string  `sql:\"column:full_name\"`\n    Email       string  `sql:\"unique\"`\n    Password    string\n    RawData     map[string]string `sql:\"ignore\"` // Add ignore tag if the field does not exists on table\n}\n\nfunc (u User) GetID() interface{} {\n\treturn u.ID\n}\n\ntype UserModel struct {\n    octopus.Model\n}\n\nfunc NewUserModel() *UserModel {\n    model :=  \u0026UserModel{}\n    config := base.DBConfig{Driver:base.PG, Host:\"localhost\", Port: \"5432\", Database: \"MyDatabase\"}\n    model.Initiate(\u0026User{}, config)\n    \n    return model\n}\n```\n\nThen you can use model like this:\n\n```go\npackage main\n\nimport (\n    \"github.com/Kamva/octopus/term\"\n\t\"models\"\n)\n\n\nfunc main() {\n\tmodel := models.NewUserModel()\n\t\n\t// Find a user by ID\n\tuser, err := model.Find(1)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\t\n\t// Create a new record\n\tnewUser := User{Name: \"John Doe\", Email: \"john.doe@email.com\", Password: \"HashedPassword\"}\n\tmodel.Create(\u0026newUser)\n\t\n\t// Update a record\n\tuser.Name = \"New Name\"\n\tmodel.Update(user)\n\t\n\t// Delete a record\n\tmodel.Delete(user)\n\t\n\t// Query the table\n\tmodel.Where(term.Equal{Field: \"name\", Value: \"John Doe\"}).First()\n}\n``` \n\n## Supported Databases\n\n- [x] MongoDB\n    - [x] Data Modelling\n    - [ ] Raw Query\n    - [ ] Aggregations\n    - [ ] Relation Support [via lookup aggregation]\n- [x] PostgreSQL\n    - [x] Data Modelling\n    - [x] Arrays and Json type support\n    - [ ] Grouping\n    - [ ] Raw Query\n    - [ ] Relation Support\n- [x] MSSQL\n    - [x] Data Modelling\n    - [ ] Grouping\n    - [ ] Raw Query\n    - [ ] Relation Support\n    - [ ] Stored Procedures\n- [ ] MySQL\n- [ ] SQLite3\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkamva%2Foctopus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkamva%2Foctopus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkamva%2Foctopus/lists"}