jaberbu / onfirework

Makes Firebase easy to use
Other
0 stars 0 forks source link

Add _ID automatic to models #16

Closed jaberbu closed 3 years ago

jaberbu commented 3 years ago

Would be great not make mandatory to add _id field to Interfaces

interface Schema { _id?: string | undefined; FIELD_1: string; FIELD_2: number; }

jaberbu commented 3 years ago

Options: imagen Results: imagen

But if you want access to first element you need to know its id: results['1ARo7ZoCFcwETOtVjjAI'].BRAND

ezequieltejada commented 3 years ago

I'll take it

jaberbu commented 3 years ago

@ezequieltejada

The idea is add _id automatically to the interface created by the user.

Interface created buy user and passed to Onfirework<Schema>('COLLECTION') imagen

And gets _id too imagen

ezequieltejada commented 3 years ago

Ups! Sorry, I miss understood. Please reject the pull request

jaberbu commented 3 years ago

Close #20

jaberbu commented 3 years ago

@ezequieltejada bad news :( works 50%

Works great as Filter suggest 👍 imagen

Not work 👎 imagen

We need reopen an issue to try solved this bug.

jaberbu commented 3 years ago

There is also the problem that requires importing Results to declared filters outside the listDocs(where)

const where:Filter<Result<BikeSchema>>[] = [
    ['BRAND', '==', 'Ducati']
]

imagen

ezequieltejada commented 3 years ago

I'll take a look on it

jaberbu commented 3 years ago

@ezequieltejada We should revert type for param Filter to Filter<T>[] is not necesary filtering by _ID

eg: bikes.listDocs([['_id', '==', '1234']])

imagen

This is other thing:

const where:Filter<Result<BikeSchema>>[] = [['BRAND', '==', 'Ducati']]
const ducati:Promise<Result<BikeSchema>[]> = bike.listDocs(where)
jaberbu commented 3 years ago

Fixed in Pull Request #22