#convex-ents friends table with sender,receiver and status union with pending accepted and rejected
3 messages · Page 1 of 1 (latest)
I'm sorry, but the knowledge sources provided do not contain a specific example of a Convex Ent schema for a friends table with sender, receiver, and status fields. However, I can guide you on how you might structure it based on the general principles of Convex and Convex Ents.
In Convex, tables are created when the first document is added to them. You don't need to specify a schema upfront or create tables explicitly. This is different from traditional SQL databases where you need to define the structure of the table before inserting data.
Convex Ents is a library built on top of Convex that provides an abstraction for managing document relationships. It allows you to define "Ents", which are entities in your application, and the relationships between them.
To create a friends table with sender, receiver, and status fields, you would first define an Ent for a Friend. The sender and receiver could be other Ent types, such as User. The status could be a string field that accepts values "pending", "accepted", and "rejected".
Here's a very basic example:
const Friend = defineEnt({
name: "Friend",
fields: {
sender: Field.ref("User"),
receiver: Field.ref("User"),
status: Field.string(),
},
edges: {
sender: Edge.toOne("User"),
receiver: Edge.toOne("User"),
},
});
Please note that this is a simplified example and might not cover all your needs. For more detailed information on how to use Convex Ents, you can check out the Convex Ents docs (https://labs.convex.dev/convex-ents) and the Convex Ents repo (https://github.com/xixixao/convex-ents).