Search Results

Search found 2 results on 1 pages for 'sics'.

Page 1/1 | 1 

  • Spring Data MongoDB Date between two Dates

    - by sics
    i'm using Spring Data for MongoDB and got the following classes class A { List<B> b; } class B { Date startDate; Date endDate; } when i save an object of A it gets persisted like { "_id" : "DQDVDE000VFP8E39", "b" : [ { "startDate" : ISODate("2009-10-05T22:00:00Z"), "endDate" : ISODate("2009-10-29T23:00:00Z") }, { "startDate" : ISODate("2009-11-01T23:00:00Z"), "endDate" : ISODate("2009-12-30T23:00:00Z") } ] } Now i want to query the db for documents matching entries in b where a given date is between startDate and endDate. Query query = new Query(Criteria.where("a").elemMatch( Criteria.where("startDate").gte(date) .and("endDate").lte(date) ); Which results in the following mongo query: { "margins": { "$elemMatch": { "startDate" : { "$gte" : { "$date" : "2009-11-03T23:00:00.000Z"}}, "endDate" : { "$lte" : { "$date" : "2009-11-03T23:00:00.000Z"}} } } } but returns no resulting documents. Does anybody know what i'm doing wrong? I don't get it... Thank you very much in advance!!

    Read the article

  • has_many :through formtastic multi-select field

    - by Tristan O'Neil
    I'm trying to set up a many to many relationship using the has_many :through method and then use a multi-select field to setup the relationships. I'm following this tutorial: http://asciicasts.com/episodes/185-formtastic-part-2 However for some reason the form displays a strange hex number and it changes each page refresh, I'm not exactly sure what I'm doing wrong. Below is my model/view code. company.rb has_many :classifications has_many :sics, :through => :classifications sic.rb has_many :classifications has_many :companies, :through => :classifications classification.rb belongs_to :company belongs_to :sic _form.html.erb <% semantic_form_for @company do |f| %> <% f.inputs do %> <%= f.input :company %> <%= f.input :sics %> <% end %> <%= f.buttons %> <% end %> Also here is the the form looks like it's showing the correct number of entries for the field but it is clearly not showing the correct name for the relationship.

    Read the article

1