Sha256: d070ff0c517dae820455689bcc7ce0953f26336e150fb610d3c787532d5a0e51

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.tap do |app|
  app.add_index(MarkLogic::DatabaseSettings::RangeElementIndex.new(:age, :type => 'int'))
end.sync

class User
  include MarkMapper::Document

  key :name, String
  key :tags, Array
end
User.collection.remove # empties collection

User.create(:name => 'John',  :tags => %w[ruby marklogic], :age => 28)
User.create(:name => 'Bill',  :tags => %w[ruby marklogic], :age => 30)
User.create(:name => 'Frank', :tags => %w[marklogic],      :age => 35)
User.create(:name => 'Steve', :tags => %w[html5 css3], :age => 27)

[

  User.all(:name => 'John'),
  User.all(:tags => %w[marklogic]),
  # User.all(:tags.all => %w[ruby marklogic]),
  User.all(:age.ge => 30),

  User.where(:age.gt => 27).sort(:age).all,
  User.where(:age.gt => 27).sort(:age.desc).all,
  User.where(:age.gt => 27).sort(:age).limit(1).all,
  User.where(:age.gt => 27).sort(:age).skip(1).limit(1).all,

].each do |result|
  pp result
  puts
end

MarkMapper.application.drop

Version data entries

6 entries across 6 versions & 1 rubygems

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