Sha256: c2a602364d0bd9916f0aa3a142a21490403b5dd58c151afe256969987f5d5e9a

Contents?: true

Size: 1.05 KB

Versions: 6

Compression:

Stored size: 1.05 KB

Contents

$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
require_relative './sample_app'
require 'pp'

MarkMapper.application.create

class User
  include MarkMapper::Document

  key :first_name,  String, :required => true
  key :last_name,   String, :required => true
  key :token,       String, :default => lambda { 'some random string' }
  key :age,         Integer
  key :skills,      Array
  key :friend_ids,  Array, :typecast => 'ObjectId'
  key :links,       Hash
  timestamps!
end
User.collection.remove # empties collection

john = User.create({
  :first_name => 'John',
  :last_name  => 'Nunemaker',
  :age        => 28,
  :skills     => ['ruby', 'marklogic', 'javascript'],
  :links      => {"Google" => "http://www.google.com"}
})

steve = User.create({
  :first_name => 'Steve',
  :last_name  => 'Smith',
  :age        => 29,
  :skills     => ['html', 'css', 'javascript', 'design'],
})

john.friend_ids << steve.id.to_s # will get typecast to ObjectId
john.links["Ruby on Rails"] = "http://www.rubyonrails.com"
john.save

pp john

MarkMapper.application.drop

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mark_mapper-0.0.6 examples/keys.rb
mark_mapper-0.0.5 examples/keys.rb
mark_mapper-0.0.4 examples/keys.rb
mark_mapper-0.0.3 examples/keys.rb
mark_mapper-0.0.2 examples/keys.rb
mark_mapper-0.0.1 examples/keys.rb