Xata is a serverless database with built-in full-text search, vector search, and file attachments. Think of it as PostgreSQL + Elasticsearch + S3 in one API.
Why Xata?
- Full-text search — built-in, no Elasticsearch needed
- Vector search — for AI/embeddings, built-in
- File attachments — attach files to records, no S3 setup
- Free tier — 15GB storage, 75 requests/second
- Branching — like Git branches for your database
Quick Start
npm install @xata.io/client
npx xata init
CRUD Operations
import { getXataClient } from './xata';
const xata = getXataClient();
// Create
const user = await xata.db.users.create({
name: 'Alice',
email: 'alice@example.com',
bio: 'Full-stack developer',
});
// Read
const users = await xata.db.users
.filter({ email: 'alice@example.com' })
.getMany();
// Update
await xata.db.users.update(user.id, { name: 'Alice Smith' });
// Delete
await xata.db.users.delete(user.id);
Full-Text Search
const results = await xata.db.posts.search('typescript tutorial', {
fuzziness: 1,
prefix: 'phrase',
highlight: { enabled: true },
filter: { status: 'published' },
page: { size: 10 },
});
results.records.forEach(r => {
console.log(r.title, r.xata.highlight);
});
Vector Search (AI)
// Store embeddings
await xata.db.documents.create({
content: 'TypeScript is awesome',
embedding: [0.1, 0.2, 0.3, ...], // 1536-dim vector
});
// Search by similarity
const similar = await xata.db.documents.vectorSearch('embedding', queryVector, {
size: 5,
filter: { category: 'tech' },
});
Aggregations
const stats = await xata.db.orders.aggregate({
totalRevenue: { sum: { column: 'amount' } },
avgOrder: { average: { column: 'amount' } },
byStatus: {
topValues: { column: 'status', size: 5 },
},
});
File Attachments
// Attach file to record
await xata.db.posts.update(postId, {
cover_image: {
base64Content: base64Data,
mediaType: 'image/png',
name: 'cover.png',
},
});
// Get file URL
const post = await xata.db.posts.read(postId);
const imageUrl = post.cover_image?.url;
Need searchable data? Check out my Apify actors for web scraping + Xata storage. Email spinov001@gmail.com for custom solutions.
Xata, Supabase, or Neon — which serverless DB do you prefer? Share below!
Top comments (0)