Skip to content

Commit bcb6852

Browse files
authored
Merge pull request #667 from objectstack-ai/copilot/fix-pnpm-dev-error
2 parents 106c6d6 + 33ba9af commit bcb6852

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

content/docs/guides/authentication.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -567,14 +567,14 @@ try {
567567
}
568568
```
569569

570-
### Migration from Other Systems
570+
### ObjectStack Field Naming
571571

572-
The plugin uses Better-Auth's native naming conventions (camelCase for fields, no table prefixes) to make migration from existing Better-Auth implementations seamless:
572+
The plugin uses ObjectStack's snake_case naming convention for field names, which is required by the ObjectStack protocol:
573573

574-
- Table names: `user`, `session`, `account`, `verification` (no `auth_` prefix)
575-
- Field names: `emailVerified`, `createdAt`, `userId` (camelCase)
574+
- Table names: `user`, `session`, `account`, `verification` (compatible with better-auth)
575+
- Field names: `email_verified`, `created_at`, `user_id` (snake_case)
576576

577-
If you're migrating from an existing Better-Auth setup, your data will work without modification.
577+
The ObjectQL adapter automatically handles field name transformation between better-auth's expectations and ObjectStack's snake_case convention, providing seamless integration while maintaining protocol compliance.
578578

579579
---
580580

packages/plugins/plugin-auth/README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Authentication & Identity Plugin for ObjectStack.
4040
- `verification` - Email/phone verification tokens (better-auth native table name)
4141
-**ObjectQL Adapter** - Custom adapter bridges better-auth to ObjectQL
4242

43-
The plugin uses [better-auth](https://www.better-auth.com/) for robust, production-ready authentication functionality. All requests are forwarded directly to better-auth's universal handler, ensuring full compatibility with all better-auth features. Data persistence is handled by ObjectQL using **better-auth's native naming conventions** (camelCase) to ensure seamless migration for existing better-auth users.
43+
The plugin uses [better-auth](https://www.better-auth.com/) for robust, production-ready authentication functionality. All requests are forwarded directly to better-auth's universal handler, ensuring full compatibility with all better-auth features. Data persistence is handled by ObjectQL using **ObjectStack's snake_case naming conventions** for field names to maintain consistency across the platform.
4444

4545
## Installation
4646

@@ -185,16 +185,16 @@ This architecture provides:
185185
The plugin uses **ObjectQL** for data persistence instead of third-party ORMs:
186186

187187
```typescript
188-
// Object definitions use better-auth's native naming conventions
188+
// Object definitions use ObjectStack's snake_case naming conventions
189189
export const AuthUser = ObjectSchema.create({
190-
name: 'user', // better-auth native table name
190+
name: 'user', // better-auth compatible table name
191191
fields: {
192192
id: Field.text({ label: 'User ID', required: true }),
193193
email: Field.email({ label: 'Email', required: true }),
194-
emailVerified: Field.boolean({ label: 'Email Verified' }), // camelCase
194+
email_verified: Field.boolean({ label: 'Email Verified' }), // snake_case
195195
name: Field.text({ label: 'Name', required: true }),
196-
createdAt: Field.datetime({ label: 'Created At' }), // camelCase
197-
updatedAt: Field.datetime({ label: 'Updated At' }), // camelCase
196+
created_at: Field.datetime({ label: 'Created At' }), // snake_case
197+
updated_at: Field.datetime({ label: 'Updated At' }), // snake_case
198198
// ... other fields
199199
},
200200
indexes: [
@@ -210,20 +210,20 @@ export const AuthUser = ObjectSchema.create({
210210
-**Type-Safe** - Zod-based schemas provide runtime + compile-time safety
211211
-**"Data as Code"** - Object definitions are versioned, declarative code
212212
-**Metadata Driven** - Supports migrations, validation, indexing via metadata
213-
-**Seamless Migration** - Uses better-auth's native naming (camelCase) for easy migration
213+
-**Compatible Schema** - Uses better-auth compatible table structure with ObjectStack's snake_case field naming
214214

215215
**Database Objects:**
216-
Uses better-auth's native table and field names for compatibility:
217-
- `user` - User accounts (id, email, name, emailVerified, createdAt, etc.)
218-
- `session` - Active sessions (id, token, userId, expiresAt, ipAddress, etc.)
219-
- `account` - OAuth provider accounts (id, providerId, accountId, userId, tokens, etc.)
220-
- `verification` - Verification tokens (id, value, identifier, expiresAt, etc.)
216+
Uses better-auth compatible table names with ObjectStack's snake_case field naming:
217+
- `user` - User accounts (id, email, name, email_verified, created_at, etc.)
218+
- `session` - Active sessions (id, token, user_id, expires_at, ip_address, etc.)
219+
- `account` - OAuth provider accounts (id, provider_id, account_id, user_id, tokens, etc.)
220+
- `verification` - Verification tokens (id, value, identifier, expires_at, etc.)
221221

222222
**Adapter:**
223-
The `createObjectQLAdapter()` function bridges better-auth's database interface to ObjectQL's IDataEngine using better-auth's native naming conventions:
223+
The `createObjectQLAdapter()` function bridges better-auth's database interface to ObjectQL's IDataEngine with field name transformation:
224224

225225
```typescript
226-
// Better-auth → ObjectQL Adapter (no name conversion needed)
226+
// Better-auth → ObjectQL Adapter (handles snake_case transformation)
227227
const adapter = createObjectQLAdapter(dataEngine);
228228

229229
// Better-auth uses this adapter for all database operations

0 commit comments

Comments
 (0)