You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(plugin-auth): use better-auth modelName/fields mapping for snake_case compatibility
- Add auth-schema-config.ts with model/field mapping constants for all 4 core auth models
- Refactor objectql-adapter.ts to use createAdapterFactory from better-auth/adapters
- Update auth-manager.ts to pass user/session/account/verification config with modelName and fields
- Add tests for schema config, factory adapter, and config verification
- Update README and authentication guide documentation
- Keep legacy createObjectQLAdapter for backward compatibility
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
- Field names: `email_verified`, `created_at`, `user_id` (snake_case)
585
585
586
-
better-auth internally uses model names like `user` and `session`. The ObjectQL adapter (`AUTH_MODEL_TO_PROTOCOL` mapping) automatically translates these to `sys_`-prefixed protocol names, providing seamless integration.
586
+
better-auth internally uses camelCase model and field names (`user`, `emailVerified`, `userId`).
587
+
The plugin bridges this gap using better-auth's official **`modelName` / `fields` schema customisation API**:
588
+
589
+
```typescript
590
+
// Declared in the betterAuth() config via AUTH_*_CONFIG constants:
The `createObjectQLAdapter()` function bridges better-auth's database interface to ObjectQL's IDataEngine. It includes a model→protocol name mapping (`AUTH_MODEL_TO_PROTOCOL`) that translates better-auth's hardcoded model names (e.g. `user`) to ObjectStack protocol names (e.g. `sys_user`):
223
+
**Schema Mapping (modelName + fields):**
225
224
226
-
```typescript
227
-
// Better-auth → ObjectQL Adapter (handles model name mapping + field transformation)
0 commit comments