Skip to content

Instantly share code, notes, and snippets.

@martimatix
Last active March 18, 2018 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martimatix/43c30af7fe44cb06d247c9da06022872 to your computer and use it in GitHub Desktop.
Save martimatix/43c30af7fe44cb06d247c9da06022872 to your computer and use it in GitHub Desktop.
Fauna DB syntax prototype
# This backwards approach wouldn't work because things like `let` and `do` would seem unnatural.
Fauna
.index('all_things_random_and_ref')
.match
.paginate(size: size, after: after)
.select('data')
.map { |_, ref| ref.get }
.query
Fauna
.index('spells_by_element')
.match('fire')
.paginate
.each do |spell|
spell.update(
data: {
spellbook: Fauna.ref('classes/spellbooks/104979509693618791')
}
)
end
# This approach mixes OOP with functional technique but just seems awkward and inconsistent.
what_to_map_over =
Fauna
.select("data")
.paginate { size: 2, after: 0 }
.match(Fauna.index("all_things_random_and_ref"))
Fauna
.query
.map what_to_map_over |_, ref| {
Fauna.get(ref)
}
Fauna
.query
.select("data")
.paginate { size: 2, after: 0 }
.match(Fauna.index("all_things_random_and_ref"))
.map [:_, :ref] |_, ref| {
Fauna.get(ref)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment