Skip to content

Commit

Permalink
submit button
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmeirlevy committed May 22, 2024
1 parent a20517c commit 9cc00d6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ createCrud<EventDoc>({
return true;
},
readOne: (_id, { tenantPayload }) => events.findOne({ _id: new ObjectId(_id), tenant: tenantPayload.sub }),
createOne: async (body, { user }) => {
const data: any = { ...body, user: user._id };
createOne: async (body, { user, tenantPayload }) => {
const data: any = { ...body, user: user._id, tenant: tenantPayload.sub };
const res = await events.insertOne(data);
data._id = res.insertedId;
return data;
},
readMany: (query, { tenantPayload }) => events.find({ tenant: tenantPayload.sub, tags: query.tags }).toArray(),
readMany: async (query, { tenantPayload }) => {
console.log(tenantPayload)
return events.find({ tenant: tenantPayload.sub }).toArray()
},
updateOne: async (_id, body: EventDoc, { user, tenantPayload }) => {
await events.updateOne({
_id: new ObjectId(_id),
Expand Down Expand Up @@ -72,7 +75,9 @@ createCrud<EventDoc>({
screens: {
create: {
structure: `
<h1>Create an event</h1>
<EditHeader>
Create the event here
</EditHeader>
<FormRowGroup>
<FormInput v-model="row.title" title="Title" />
<FormInput v-model="row.description" title="Description" />
Expand Down

0 comments on commit 9cc00d6

Please sign in to comment.