# GdatastoreMapper GdatastoreMapper is a mapper framework for Google Cloud Datastore in Ruby / Ruby on Rails. Once you install GdatastoreMapper you can use Google Cloud Datastore like ActiveRecord. ## Installation Add this line to your application's Gemfile: ```ruby gem 'gdatastore_mapper' ``` And then execute: $ bundle Or install it yourself as: $ gem install gdatastore_mapper ## Configuration GdatastoreMapper 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. ``` # config/database.yml production: dataset_id: your-google-cloud-platform-project-id staging: dataset_id: your-google-cloud-platform-project-id development: dataset_id: your-google-cloud-platform-project-id emulator_host: localhost:8444 test: dataset_id: your-google-cloud-platform-project-id emulator_host: localhost:8444 ``` ## Usage Only 2 things you need to do. 1. To include GdatastoreMapper 2. To set attr_accessor as column That's it! ```ruby class Book include GdatastoreMapper::Base attr_accessor :title, :author end ``` ## Persistence Methods ``` book = Book.new book.title = 'Harry Potter' book.save ``` ``` book = Book.new(title: 'Harry Potter') book.save ``` ``` Book.create(title: 'Harry Potter') ``` ``` book.update(title: 'Harry Potter 2') ``` ``` book.delete ``` ## Scoping Methods ``` Book.where(title: 'Harry Potter') => [#] ``` ``` Book.find(12) => # ``` ``` Book.find_by(title: 'Harry Potter') => # [# # # 100 ``` ``` Book.all => [# [# 2 ``` ``` harry_poter.author => [#