import {Model} from "@nozbe/watermelondb"; import {field, date, action} from…
- User
import {Model} from "@nozbe/watermelondb"; import {field, date, action} from "@nozbe/watermelondb/decorators";
class Strike extends Model { static table = 'strikes'; static associations = { categories: { type: 'has_many', foreignKey: 'strike_id' }, }
@field('title') title; @field('start_date') start_date; @field('end_date') end_date; @field('organization') organization; @field('description') description; @date('date') date; @action('delete') async delete() { await this.markAsDeleted(); await this.destroyPermanently(); }}
export default Strike;
- Assistant
Your
Strikemodel appears to be properly set up with WatermelonDB. However, I noticed a few minor points that could use some attention to ensure its optimal usage:-
Field Types for Dates: You mentioned
start_date,end_date, anddatefields, but WatermelonDB uses@datefor date fields. Ensure that your start and end dates are also recognized as date types.
-
- User
1241: Unable to resolve signature of method decorator when called as an expression. The runtime will invoke the decorator with 2 arguments, but the decorator expects 3 lib.decorators.legacy.d.ts(21, 82): An argument for descriptor was not provided.
- Assistant
The error you encountered suggests that there's a mismatch in the expected number of arguments for the decorators you're using. In WatermelonDB, decorators like
field,date, andactionshould be applied directly, without the need for additional arguments. The issue typically arises when the decorators aren't applied correctly as per TypeScript's expectations. - User
// src/screens/StrikesScreen.tsx import React, { useState, useEffect } from 'react'; import { FlatList, View } from 'react-native'; import {List, FAB, IconButton, TextInput} from 'react-native-paper'; import database from '../database';
- Assistant
- User
for strikesList and strikesList : TS2345: Argument of type Model[] is not assignable to parameter of type SetStateAction<never[]>
- Assistant
- User
setStrikes(strikesWithDetails); setFilteredStrikes(strikesWithDetails); errors : TS2345: Argument of type { id: string; title: string | undefined; start_date: Date | undefined; end_date: Date | undefined; organization: string | undefined; description: string | undefined; date: Date | undefined; }[] is not assignable to parameter of type SetStateAction<Strike[]>
- Assistant
- User
in const handleSearch = (query: string) => { setSearchQuery(query); setFilteredStrikes(strikes.filter(s => s.title.toLowerCase().includes(query.toLowerCase()))); } : TS2345: Argument of type IStrike[] is not assignable to parameter of type SetStateAction<Strike[]> Type IStrike[] is not assignable to type Strike[] Type IStrike is missing the following properties from type Strik
- Assistant
- User
5: Argument of type IStrike[] is not assignable to parameter of type SetStateAction<Strike[]> Type IStrike[] is not assignable to type Strike[] Type IStrike is
- Assistant