Skip to content

Commit 564df84

Browse files
ldanilekConvex, Inc.
authored and
Convex, Inc.
committed
revert db.table even within components (#28742)
GitOrigin-RevId: e15ea13cce499349ee27ce6c1a4e57ac6700edfa
1 parent f452e61 commit 564df84

File tree

5 files changed

+59
-78
lines changed

5 files changed

+59
-78
lines changed

npm-packages/component-tests/component/_generated/server.d.ts

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
import {
1313
ActionBuilder,
1414
HttpActionBuilder,
15-
MutationBuilderWithTable,
16-
QueryBuilderWithTable,
15+
MutationBuilder,
16+
QueryBuilder,
1717
GenericActionCtx,
18-
GenericMutationCtxWithTable,
19-
GenericQueryCtxWithTable,
20-
GenericDatabaseReaderWithTable,
21-
GenericDatabaseWriterWithTable,
18+
GenericMutationCtx,
19+
GenericQueryCtx,
20+
GenericDatabaseReader,
21+
GenericDatabaseWriter,
2222
FunctionReference,
2323
} from "convex/server";
2424
import type { DataModel } from "./dataModel.js";
@@ -36,7 +36,7 @@ type GenericCtx =
3636
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
3737
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
3838
*/
39-
export declare const query: QueryBuilderWithTable<DataModel, "public">;
39+
export declare const query: QueryBuilder<DataModel, "public">;
4040

4141
/**
4242
* Define a query that is only accessible from other Convex functions (but not from the client).
@@ -46,10 +46,7 @@ export declare const query: QueryBuilderWithTable<DataModel, "public">;
4646
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
4747
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
4848
*/
49-
export declare const internalQuery: QueryBuilderWithTable<
50-
DataModel,
51-
"internal"
52-
>;
49+
export declare const internalQuery: QueryBuilder<DataModel, "internal">;
5350

5451
/**
5552
* Define a mutation in this Convex app's public API.
@@ -59,7 +56,7 @@ export declare const internalQuery: QueryBuilderWithTable<
5956
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
6057
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
6158
*/
62-
export declare const mutation: MutationBuilderWithTable<DataModel, "public">;
59+
export declare const mutation: MutationBuilder<DataModel, "public">;
6360

6461
/**
6562
* Define a mutation that is only accessible from other Convex functions (but not from the client).
@@ -69,10 +66,7 @@ export declare const mutation: MutationBuilderWithTable<DataModel, "public">;
6966
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
7067
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
7168
*/
72-
export declare const internalMutation: MutationBuilderWithTable<
73-
DataModel,
74-
"internal"
75-
>;
69+
export declare const internalMutation: MutationBuilder<DataModel, "internal">;
7670

7771
/**
7872
* Define an action in this Convex app's public API.
@@ -116,15 +110,15 @@ export declare const httpAction: HttpActionBuilder;
116110
* This differs from the {@link MutationCtx} because all of the services are
117111
* read-only.
118112
*/
119-
export type QueryCtx = GenericQueryCtxWithTable<DataModel>;
113+
export type QueryCtx = GenericQueryCtx<DataModel>;
120114

121115
/**
122116
* A set of services for use within Convex mutation functions.
123117
*
124118
* The mutation context is passed as the first argument to any Convex mutation
125119
* function run on the server.
126120
*/
127-
export type MutationCtx = GenericMutationCtxWithTable<DataModel>;
121+
export type MutationCtx = GenericMutationCtx<DataModel>;
128122

129123
/**
130124
* A set of services for use within Convex action functions.
@@ -141,7 +135,7 @@ export type ActionCtx = GenericActionCtx<DataModel>;
141135
* document by its {@link Id}, or {@link DatabaseReader.query}, which starts
142136
* building a query.
143137
*/
144-
export type DatabaseReader = GenericDatabaseReaderWithTable<DataModel>;
138+
export type DatabaseReader = GenericDatabaseReader<DataModel>;
145139

146140
/**
147141
* An interface to read from and write to the database within Convex mutation
@@ -152,7 +146,7 @@ export type DatabaseReader = GenericDatabaseReaderWithTable<DataModel>;
152146
* your data in an inconsistent state. See [the Convex Guide](https://docs.convex.dev/understanding/convex-fundamentals/functions#atomicity-and-optimistic-concurrency-control)
153147
* for the guarantees Convex provides your functions.
154148
*/
155-
export type DatabaseWriter = GenericDatabaseWriterWithTable<DataModel>;
149+
export type DatabaseWriter = GenericDatabaseWriter<DataModel>;
156150

157151
export declare const component: {};
158152
type ComponentArgs = {

npm-packages/component-tests/component/messages.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import { mutation, query, action, componentArg } from "./_generated/server";
44
export const listMessages = query({
55
args: {},
66
handler: async (ctx) => {
7-
return await ctx.db.table("messages").query().take(10);
7+
return await ctx.db.query("messages").take(10);
88
},
99
});
1010

1111
export const insertMessage = mutation({
1212
args: { channel: v.string(), text: v.string() },
1313
handler: async (ctx, { channel, text }) => {
14-
return await ctx.db.table("messages").insert({ channel, text });
14+
return await ctx.db.insert("messages", { channel, text });
1515
},
1616
});
1717

npm-packages/component-tests/envVars/_generated/server.d.ts

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
import {
1313
ActionBuilder,
1414
HttpActionBuilder,
15-
MutationBuilderWithTable,
16-
QueryBuilderWithTable,
15+
MutationBuilder,
16+
QueryBuilder,
1717
GenericActionCtx,
18-
GenericMutationCtxWithTable,
19-
GenericQueryCtxWithTable,
20-
GenericDatabaseReaderWithTable,
21-
GenericDatabaseWriterWithTable,
18+
GenericMutationCtx,
19+
GenericQueryCtx,
20+
GenericDatabaseReader,
21+
GenericDatabaseWriter,
2222
FunctionReference,
2323
} from "convex/server";
2424
import type { DataModel } from "./dataModel.js";
@@ -36,7 +36,7 @@ type GenericCtx =
3636
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
3737
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
3838
*/
39-
export declare const query: QueryBuilderWithTable<DataModel, "public">;
39+
export declare const query: QueryBuilder<DataModel, "public">;
4040

4141
/**
4242
* Define a query that is only accessible from other Convex functions (but not from the client).
@@ -46,10 +46,7 @@ export declare const query: QueryBuilderWithTable<DataModel, "public">;
4646
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
4747
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
4848
*/
49-
export declare const internalQuery: QueryBuilderWithTable<
50-
DataModel,
51-
"internal"
52-
>;
49+
export declare const internalQuery: QueryBuilder<DataModel, "internal">;
5350

5451
/**
5552
* Define a mutation in this Convex app's public API.
@@ -59,7 +56,7 @@ export declare const internalQuery: QueryBuilderWithTable<
5956
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
6057
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
6158
*/
62-
export declare const mutation: MutationBuilderWithTable<DataModel, "public">;
59+
export declare const mutation: MutationBuilder<DataModel, "public">;
6360

6461
/**
6562
* Define a mutation that is only accessible from other Convex functions (but not from the client).
@@ -69,10 +66,7 @@ export declare const mutation: MutationBuilderWithTable<DataModel, "public">;
6966
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
7067
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
7168
*/
72-
export declare const internalMutation: MutationBuilderWithTable<
73-
DataModel,
74-
"internal"
75-
>;
69+
export declare const internalMutation: MutationBuilder<DataModel, "internal">;
7670

7771
/**
7872
* Define an action in this Convex app's public API.
@@ -116,15 +110,15 @@ export declare const httpAction: HttpActionBuilder;
116110
* This differs from the {@link MutationCtx} because all of the services are
117111
* read-only.
118112
*/
119-
export type QueryCtx = GenericQueryCtxWithTable<DataModel>;
113+
export type QueryCtx = GenericQueryCtx<DataModel>;
120114

121115
/**
122116
* A set of services for use within Convex mutation functions.
123117
*
124118
* The mutation context is passed as the first argument to any Convex mutation
125119
* function run on the server.
126120
*/
127-
export type MutationCtx = GenericMutationCtxWithTable<DataModel>;
121+
export type MutationCtx = GenericMutationCtx<DataModel>;
128122

129123
/**
130124
* A set of services for use within Convex action functions.
@@ -141,7 +135,7 @@ export type ActionCtx = GenericActionCtx<DataModel>;
141135
* document by its {@link Id}, or {@link DatabaseReader.query}, which starts
142136
* building a query.
143137
*/
144-
export type DatabaseReader = GenericDatabaseReaderWithTable<DataModel>;
138+
export type DatabaseReader = GenericDatabaseReader<DataModel>;
145139

146140
/**
147141
* An interface to read from and write to the database within Convex mutation
@@ -152,7 +146,7 @@ export type DatabaseReader = GenericDatabaseReaderWithTable<DataModel>;
152146
* your data in an inconsistent state. See [the Convex Guide](https://docs.convex.dev/understanding/convex-fundamentals/functions#atomicity-and-optimistic-concurrency-control)
153147
* for the guarantees Convex provides your functions.
154148
*/
155-
export type DatabaseWriter = GenericDatabaseWriterWithTable<DataModel>;
149+
export type DatabaseWriter = GenericDatabaseWriter<DataModel>;
156150

157151
export declare const component: {
158152
component: {

npm-packages/component-tests/errors/_generated/server.d.ts

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
import {
1313
ActionBuilder,
1414
HttpActionBuilder,
15-
MutationBuilderWithTable,
16-
QueryBuilderWithTable,
15+
MutationBuilder,
16+
QueryBuilder,
1717
GenericActionCtx,
18-
GenericMutationCtxWithTable,
19-
GenericQueryCtxWithTable,
20-
GenericDatabaseReaderWithTable,
21-
GenericDatabaseWriterWithTable,
18+
GenericMutationCtx,
19+
GenericQueryCtx,
20+
GenericDatabaseReader,
21+
GenericDatabaseWriter,
2222
FunctionReference,
2323
} from "convex/server";
2424
import type { DataModel } from "./dataModel.js";
@@ -36,7 +36,7 @@ type GenericCtx =
3636
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
3737
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
3838
*/
39-
export declare const query: QueryBuilderWithTable<DataModel, "public">;
39+
export declare const query: QueryBuilder<DataModel, "public">;
4040

4141
/**
4242
* Define a query that is only accessible from other Convex functions (but not from the client).
@@ -46,10 +46,7 @@ export declare const query: QueryBuilderWithTable<DataModel, "public">;
4646
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
4747
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
4848
*/
49-
export declare const internalQuery: QueryBuilderWithTable<
50-
DataModel,
51-
"internal"
52-
>;
49+
export declare const internalQuery: QueryBuilder<DataModel, "internal">;
5350

5451
/**
5552
* Define a mutation in this Convex app's public API.
@@ -59,7 +56,7 @@ export declare const internalQuery: QueryBuilderWithTable<
5956
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
6057
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
6158
*/
62-
export declare const mutation: MutationBuilderWithTable<DataModel, "public">;
59+
export declare const mutation: MutationBuilder<DataModel, "public">;
6360

6461
/**
6562
* Define a mutation that is only accessible from other Convex functions (but not from the client).
@@ -69,10 +66,7 @@ export declare const mutation: MutationBuilderWithTable<DataModel, "public">;
6966
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
7067
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
7168
*/
72-
export declare const internalMutation: MutationBuilderWithTable<
73-
DataModel,
74-
"internal"
75-
>;
69+
export declare const internalMutation: MutationBuilder<DataModel, "internal">;
7670

7771
/**
7872
* Define an action in this Convex app's public API.
@@ -116,15 +110,15 @@ export declare const httpAction: HttpActionBuilder;
116110
* This differs from the {@link MutationCtx} because all of the services are
117111
* read-only.
118112
*/
119-
export type QueryCtx = GenericQueryCtxWithTable<DataModel>;
113+
export type QueryCtx = GenericQueryCtx<DataModel>;
120114

121115
/**
122116
* A set of services for use within Convex mutation functions.
123117
*
124118
* The mutation context is passed as the first argument to any Convex mutation
125119
* function run on the server.
126120
*/
127-
export type MutationCtx = GenericMutationCtxWithTable<DataModel>;
121+
export type MutationCtx = GenericMutationCtx<DataModel>;
128122

129123
/**
130124
* A set of services for use within Convex action functions.
@@ -141,7 +135,7 @@ export type ActionCtx = GenericActionCtx<DataModel>;
141135
* document by its {@link Id}, or {@link DatabaseReader.query}, which starts
142136
* building a query.
143137
*/
144-
export type DatabaseReader = GenericDatabaseReaderWithTable<DataModel>;
138+
export type DatabaseReader = GenericDatabaseReader<DataModel>;
145139

146140
/**
147141
* An interface to read from and write to the database within Convex mutation
@@ -152,7 +146,7 @@ export type DatabaseReader = GenericDatabaseReaderWithTable<DataModel>;
152146
* your data in an inconsistent state. See [the Convex Guide](https://docs.convex.dev/understanding/convex-fundamentals/functions#atomicity-and-optimistic-concurrency-control)
153147
* for the guarantees Convex provides your functions.
154148
*/
155-
export type DatabaseWriter = GenericDatabaseWriterWithTable<DataModel>;
149+
export type DatabaseWriter = GenericDatabaseWriter<DataModel>;
156150

157151
export declare const component: {};
158152
type ComponentArgs = {};

0 commit comments

Comments
 (0)