Hello!
I’m fairly new to meteor, so here come some stupid questions in the beginning.
I have set up JS file Month.jsx in ui, which contains:
export const Month = ({ month }) => {
const days = getDaysArray(2023, 01)return { days.map(day => <Day key={ day.day } day={ day }/>) }
};
I want to do the mongodb query of this month days, and for some days I get the result, for other days no. I would like to set the unique index to be Date - is this possible? Then, I want to pass the date object of every day, as I get it from DB, to this Day where I have day={day}, but I interate over this array, not over the DB result set - so I have to do the second query to the result set, to get specific day. Can I somehow organize the mongodb result so that I get something like this:
import { DaysCollection } from ‘/imports/api/DaysCollection’;
export const Month = ({ month }) => {
// Here how to select the days from DaysCollection for this month into an object so that the following is possible…
DaysCollection.find({“day”: {“gte”: new Date(2023, 01-1, 1), “lt”: new Date(2023, 01, 1)}}).fetch()
const days = getDaysArray(2023, 01)return { days.map(day => <Day key={ day.day /* here, is the date type of key possible? / } day={ / here, the item which gets this specific day from the dayscollection object, but only if it exists */ }/>) }
};
Is this the right mongodb query dor day in january of 2023? It should be greater or equal to 1’st jan. of 2023 and smaller than 1’st feb.? Now I don’t know the accessor to this array such that for any given day, I get the item for this day - I can iterate over the days array, but I do not want to iterate, I want to get the value for a given day as I iterate over another object, all the days in a month.