MCPcopy Create free account
hub / github.com/TanStack/db / makeInvalidDateCollection

Function makeInvalidDateCollection

packages/db/tests/collection-indexes.test.ts:1660–1688  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1658 // float semantics as NaN: equal to one another and greater than every valid
1659 // Date. The index-served and full-scan results must agree.
1660 const makeInvalidDateCollection = async () => {
1661 const dateCollection = createCollection<
1662 { id: string; createdAt: Date },
1663 string
1664 >({
1665 getKey: (row) => row.id,
1666 startSync: true,
1667 autoIndex: `off`,
1668 defaultIndexType: BTreeIndex,
1669 sync: {
1670 sync: ({ begin, write, commit, markReady }) => {
1671 begin()
1672 write({
1673 type: `insert`,
1674 value: { id: `invalid`, createdAt: new Date(`not a date`) },
1675 })
1676 write({
1677 type: `insert`,
1678 value: { id: `valid`, createdAt: new Date(`2023-01-01`) },
1679 })
1680 commit()
1681 markReady()
1682 },
1683 },
1684 })
1685 await dateCollection.stateWhenReady()
1686 dateCollection.createIndex((row) => row.createdAt)
1687 return dateCollection
1688 }
1689
1690 it(`should match an invalid-Date row for an equality on an invalid Date`, async () => {
1691 const dateCollection = await makeInvalidDateCollection()

Callers 1

Calls 3

createCollectionFunction · 0.85
stateWhenReadyMethod · 0.80
createIndexMethod · 0.45

Tested by

no test coverage detected