convex-helpers
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -1,1 +0,28 @@ | ||
"use strict"; | ||
import { defineTable } from "convex/server"; | ||
import { v } from "convex/values"; | ||
/** | ||
* | ||
* @param name The table name. This should also be used in defineSchema. | ||
* @param fields Table fields, as you'd pass to defineTable. | ||
* @returns Object of shape: { | ||
* table: from defineTable, | ||
* withSystemFields: Input fields with _id and _creationTime, | ||
* withoutSystemFields: The fields passed in, | ||
* doc: a validator for the table doc as a v.object(). This is useful when | ||
* defining arguments to actions where you're passing whole documents. | ||
* } | ||
*/ | ||
export function Table(name, fields) { | ||
const table = defineTable(fields); | ||
const withSystemFields = { | ||
...fields, | ||
_id: v.id(name), | ||
_creationTime: v.number(), | ||
}; | ||
return { | ||
table, | ||
doc: v.object(withSystemFields), | ||
withoutSystemFields: fields, | ||
withSystemFields, | ||
}; | ||
} |
{ | ||
"name": "convex-helpers", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "A collection of useful code to complement the official convex package.", | ||
@@ -5,0 +5,0 @@ "exports": { |
Sorry, the diff of this file is not supported yet
134358
2763