Last active
March 18, 2018 01:59
-
-
Save martimatix/43c30af7fe44cb06d247c9da06022872 to your computer and use it in GitHub Desktop.
Fauna DB syntax prototype
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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