{"id":29058646,"url":"https://github.com/shinyak14/gdatastore_mapper","last_synced_at":"2026-04-28T01:31:09.289Z","repository":{"id":56873678,"uuid":"87292990","full_name":"shinyaK14/gdatastore_mapper","owner":"shinyaK14","description":"Google Cloud Datastore Mapper in Ruby / Ruby on Rails","archived":false,"fork":false,"pushed_at":"2017-05-03T18:47:39.000Z","size":93,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-27T07:02:24.906Z","etag":null,"topics":["google-cloud-datastore","rails","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/shinyaK14.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-05T09:44:34.000Z","updated_at":"2017-05-04T20:38:55.000Z","dependencies_parsed_at":"2022-08-20T22:30:31.746Z","dependency_job_id":null,"html_url":"https://github.com/shinyaK14/gdatastore_mapper","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/shinyaK14/gdatastore_mapper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinyaK14%2Fgdatastore_mapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinyaK14%2Fgdatastore_mapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinyaK14%2Fgdatastore_mapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinyaK14%2Fgdatastore_mapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shinyaK14","download_url":"https://codeload.github.com/shinyaK14/gdatastore_mapper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinyaK14%2Fgdatastore_mapper/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262210085,"owners_count":23275488,"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":["google-cloud-datastore","rails","ruby"],"created_at":"2025-06-27T07:01:40.245Z","updated_at":"2026-04-28T01:31:09.262Z","avatar_url":"https://github.com/shinyaK14.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GdatastoreMapper\n[![CircleCI](https://circleci.com/gh/shinyaK14/gdatastore_mapper/tree/master.svg?style=svg)](https://circleci.com/gh/shinyaK14/gdatastore_mapper/tree/master)  [![Gem Version](https://badge.fury.io/rb/gdatastore_mapper.svg)](https://badge.fury.io/rb/gdatastore_mapper)\n\nGdatastoreMapper is a mapper framework for Google Cloud Datastore in Ruby / Ruby on Rails.\nOnce you install GdatastoreMapper you can use Google Cloud Datastore like ActiveRecord.\n\n## Table of Contents\n- [Demo](#demo)\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Configuration](#configuration)\n- [Model Setting](#model-setting)\n- [Persistence Methods](#persistence-methods)\n- [Scoping Methods](#scoping-methods)\n- [Timestamp](#timestamp)\n- [Associations](#associations)\n  - [One to Many](#one-to-many)\n  - [Method Chaining](#method-chaining)\n- [Callbacks](#callbacks)\n- [Validations](#validations)\n- [Contact](#contact)\n- [Development](#development)\n\n## Demo\n\nHere is [demo](https://gdatastore-mapper.herokuapp.com/). The demo works with Google Cloud Datastore.\n\nSource code is [here](https://github.com/shinyaK14/gdatastore_mapper/tree/master/rails_example).\n\n## Requirements\n\nGdatastoreMapper requires Rails version \u003e= 5\n\n\n## Installation\n\nExecute rails new with --skip-active-record\n```\n$ rails new your_project --skip-active-record\n```\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'gdatastore_mapper'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install gdatastore_mapper\n\n## Configuration\n\nGdatastoreMapper configuration can be done through a database.yml. The simplest configuration is as follows, which sets the emulator_host to \"localhost:8444\" and dataset_id.\n\n```\n# config/database.yml\nproduction:\n  dataset_id: your-google-cloud-platform-project-id\n\nstaging:\n  dataset_id: your-google-cloud-platform-project-id\n\ndevelopment:\n  dataset_id: your-google-cloud-platform-project-id\n  emulator_host: localhost:8444\n\ntest:\n  dataset_id: your-google-cloud-platform-project-id\n  emulator_host: localhost:8444\n```\n\n## Model Setting\n\nOnly 2 things you need to do.\n\n1. To include GdatastoreMapper\n2. To set attr_accessor as column\n\nThat's it! No need to db:migrate.\n\n```ruby\nclass Book\n  include GdatastoreMapper::Base\n\n  attr_accessor :title, :author\nend\n```\n\n## Persistence Methods\n\nnew record\n\n```\nbook = Book.new\nbook.title = 'Harry Potter'\nbook.save\n```\n```\nbook = Book.new(title: 'Harry Potter')\nbook.save\n```\n```\nBook.create(title: 'Harry Potter')\n```\n\nupdate\n\n```\nbook.update(title: 'Harry Potter 2')\n```\n\ndelete\n\n```\nbook.delete\n```\n```\nBook.delete_all\n```\n\n## Scoping Methods\n\n```\nBook.where(title: 'Harry Potter')\n=\u003e [#\u003cBook:0x00 @created_at=2017-04-08 21:22:31 +0200, @title=\"Harry Potter\",\n    @id=70, @updated_at=2017-04-08 21:22:31 +0200\u003e]\n```\n```\nBook.find(12)\n=\u003e #\u003cBook:0x00 @created_at=2017-04-07 10:03:54 +0200, @title=\"Harry Potter\",\n    @id=12, @updated_at=2017-04-07 22:57:57 +0200\u003e\n```\n```\nBook.find_by(title: 'Harry Potter')\n=\u003e #\u003cBook:0x00 @title=\"Harry Potter\" ....\n```\n```\nBook.order(title: :asc)\n=\u003e [#\u003cBook:0x00 @title=\"Harry Potter\" .... ]\n```\n\n```\nBook.first\n=\u003e #\u003cBook:0x00 @title=\"Harry Potter\" ....\n```\n```\nBook.last\n=\u003e #\u003cBook:0x00 @title=\"Harry Potter\" ....\n```\n```\nBook.count\n=\u003e 100\n```\n```\nBook.all\n=\u003e [#\u003cBook:0x00 @title=\"Harry Potter\" .... ]\n```\n\n## Timestamp\n\nAll records have created_at and updated_at. They will be updated automatically.\n\n## Associations\n\n### One to Many\nAssociations can be set the same as Active Record.\n\nexample of one to many relationship\n\n```ruby\nclass Book\n  include GdatastoreMapper::Base\n\n  attr_accessor :title\n\n  belongs_to :author\nend\n```\n\n```ruby\nclass Author\n  include GdatastoreMapper::Base\n\n  attr_accessor :name\n\n  has_many :books\nend\n```\n\nbooks.create\n```\nrowling = Author.create(name: 'J. K. Rowling')\nharry_poter = rolling.books.create(title: 'Harry Poter')\nharry_poter2 = rolling.books.create(title: 'Harry Poter 2')\n```\nbooks\n```\nrowling.books\n=\u003e [#\u003cBook:0x00 @title=\"Harry Potter\" .... ]\n```\n\nbooks.count\n```\nrowling.books.count\n=\u003e 2\n```\n```\nharry_poter.author\n=\u003e [#\u003cAuthor:0x00 @name=\"J. K. Rowling\" .... ]\n```\n### Method Chaining\n\n```\nrowling.books.order(created_at: :desc).limit(3)\n=\u003e [#\u003cBook:0x00 @title=\"Harry Potter\" .... ]\n```\n```\nrowling.books.where(series: 'Harry Potter').order(published_at: :asc).limit(3)\n=\u003e [#\u003cBook:0x00 @title=\"Harry Potter\" .... ]\n```\n\n## Callbacks\n\n```ruby\nclass Book\n  include GdatastoreMapper::Base\n\n  before_save :something_before_save\n\n  private\n  def something_before_save\n    something that you want\n  end\n\nend\n```\n\n## Validations\n\n```ruby\nclass Author\n  include GdatastoreMapper::Base\n\n  attr_accessor :email\n\n  validates :email, presence: true, format: { with: /\\A([^@\\s]+)@((?:[-a-z0-9]+\\.)+[a-z]{2,})\\z/i }\n  validates :email, length: { in: 3..20 }\n  validates_uniqueness_of :email\nend\n```\n\n\n## Contact\n\nPlease shoot me an e-mail if you find any issues, ideas and comments. shinya.kitamura.14@gmail.com\nThanks!\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/shinyaK14/gdatastore_mapper. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinyak14%2Fgdatastore_mapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshinyak14%2Fgdatastore_mapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinyak14%2Fgdatastore_mapper/lists"}