- Implement PostgreSQL database schema with users and bookmarks tables - Add database connection pooling with retry logic and error handling - Create migration system with automatic schema initialization - Add database CLI tools for management (init, status, validate, etc.) - Include comprehensive error handling and diagnostics - Add development seed data and testing utilities - Implement health monitoring and connection pool statistics - Create detailed documentation and troubleshooting guide Database features: - Users table with authentication fields and email verification - Bookmarks table with user association and metadata - Proper indexes for performance optimization - Automatic timestamp triggers - Transaction support with rollback handling - Connection pooling (20 max connections, 30s idle timeout) - Graceful shutdown handling CLI commands available: - npm run db:init - Initialize database - npm run db:status - Check database status - npm run db:validate - Validate schema - npm run db:test - Run database tests - npm run db:diagnostics - Full diagnostics
34 lines
1.5 KiB
JavaScript
34 lines
1.5 KiB
JavaScript
// Test the folder population logic
|
|
const testBookmarks = [
|
|
{ id: 1, title: "Test 1", url: "https://example.com", folder: "Development" },
|
|
{ id: 2, title: "Test 2", url: "https://example2.com", folder: "Development / Tools" },
|
|
{ id: 3, title: "Test 3", url: "https://example3.com", folder: "Personal" },
|
|
{ id: 4, title: "Test 4", url: "https://example4.com", folder: "Development" },
|
|
{ id: 5, title: "Test 5", url: "https://example5.com", folder: "" },
|
|
{ id: 6, title: "Test 6", url: "https://example6.com", folder: "Personal / Finance" }
|
|
];
|
|
|
|
// Simulate the populateFolderList logic
|
|
function testPopulateFolderList(bookmarks) {
|
|
// Get unique folder names from existing bookmarks
|
|
const uniqueFolders = [...new Set(
|
|
bookmarks
|
|
.map(bookmark => bookmark.folder)
|
|
.filter(folder => folder && folder.trim() !== '')
|
|
)].sort();
|
|
|
|
console.log('Test Bookmarks:', bookmarks.length);
|
|
console.log('Unique Folders Found:', uniqueFolders);
|
|
console.log('Expected Folders: ["Development", "Development / Tools", "Personal", "Personal / Finance"]');
|
|
|
|
// Verify the logic
|
|
const expectedFolders = ["Development", "Development / Tools", "Personal", "Personal / Finance"];
|
|
const isCorrect = JSON.stringify(uniqueFolders) === JSON.stringify(expectedFolders);
|
|
|
|
console.log('Test Result:', isCorrect ? '✅ PASS' : '❌ FAIL');
|
|
|
|
return uniqueFolders;
|
|
}
|
|
|
|
// Run the test
|
|
testPopulateFolderList(testBookmarks); |