Created
February 24, 2016 19:30
-
-
Save jfinucane/0e21fc39a13d51970cfb to your computer and use it in GitHub Desktop.
Dental plan results affected by Mongo query syntax
This file contains hidden or 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
# Snippet illustrates a query on hbx_enrollemnts | |
# FINDS familes including ones that have ivl dental and employer_sponsored health | |
families = Family.where(:"households.hbx_enrollments.kind" => "employer_sponsored", :"households.hbx_enrollments.coverage_kind" => 'dental') | |
puts families.size #36 | |
# FINDS families where the enrollment has coverage_kind='dental' and kind: 'employer_sponsored' | |
families=Family.where(:'households.hbx_enrollments' => | |
{ | |
"$elemMatch" => { | |
kind: 'employer_sponsored', | |
coverage_kind: 'dental' | |
} | |
}) | |
puts families.size # 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment