Skip to content

Instantly share code, notes, and snippets.

View sle-c's full-sized avatar
🏠
Working from home

Si Le sle-c

🏠
Working from home
View GitHub Profile
@sle-c
sle-c / active_record_json_cheatsheet.rb
Last active March 15, 2024 23:48 — forked from mabenson00/cheatsheet.rb
Rails ActiveRecord JSON cheatsheet
# Basic key operators to query the JSON objects :
# #> : Get the JSON object at that path (if you need to do something fancy)
# -> : Get the JSON object at that path (if you don't)
# ->> : Get the JSON object at that path as text
# {obj, n} : Get the nth item in that object
# https://www.postgresql.org/docs/9.4/functions-json.html#FUNCTIONS-JSONB-OP-TABLE
# Date
# date before today