get-convex / convex-ents

https://labs.convex.dev/convex-ents
25 stars 5 forks source link

Type 'TableName' does not satisfy the constraint #27

Closed AyoCodess closed 5 months ago

AyoCodess commented 5 months ago

Hey, following the convex-ents documentation, i ran into a type issue with when importing the types.ts, am i doing something wrong?, At this point im just copying and pasting boiler plate for set up, theres nothing usual abut my setup.

my schema

import { defineEnt, defineEntSchema, getEntDefinitions } from 'convex-ents';
import { v } from 'convex/values';

const schema = defineEntSchema({
  emailList: defineEnt({
    email: v.string(),
    type: v.string(),
    message: v.optional(v.string())
  })
    .index('byEmail', ['email'])
    .index('byType', ['type']),

  messages: defineEnt({
    author: v.string(),
    body: v.string()
  }),

  users: defineEnt({
    email: v.string(),
    name: v.optional(v.string()),
    tokenIdentifier: v.string(),
    isDeleted: v.boolean(),
    updatedAt: v.optional(v.string()),
    updateCount: v.optional(v.number())
  })
    .index('byEmail', ['email'])
    .index('byToken', ['tokenIdentifier'])
});

export const entDefinitions = getEntDefinitions(schema);

Screenshot 2024-06-15 at 09 09 58 Screenshot 2024-06-15 at 09 10 13

AyoCodess commented 5 months ago

fixed

lbybrilee commented 2 months ago

How did you fix this? I'm running into the same problem. i'm sure I made a small error when setting up everything as this is the only issue that references this error but I can't seem to figure it out.

lbybrilee commented 2 months ago

Oh I found it. Like I suspected, it was a very basic error that was missed while I was modifying my preexisting code to migrate to ents. Basically, you just need to make sure you have the two lines as at the end of schema.ts like it says in the documentation:

export default schema;
export const entDefinitions = getEntDefinitions(schema);