Creating a new table with all optional fields can be a solution, but it might not be the most efficient or cleanest way to handle this situation. It could lead to redundancy and unnecessary complexity in your schema.
Instead, you might want to consider creating a separate validator for the optional fields and use it in your mutation. This way, you can avoid duplicating your entire table schema and keep your code cleaner and more maintainable.
Here's an example:
const optionalOrderFields = {
field1: v.optional(v.string()),
field2: v.optional(v.number()),
};
export const editOrder = mutation({
args: {
orderId: v.id('orders'),
orderEditedProperties: v.object(optionalOrderFields),
},
});
In this code, replace field1, field2, etc., with the actual field names of your orders table and use the appropriate validators (v.string(), v.number(), etc.) based on the field types.
Remember, the key is to keep your schema as simple and maintainable as possible.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: