Lesson 2 / 96 min read
Data API: devany.db and devany.user
Shared collections vs the per-user store — same shape, different scope.
Shared data (devany.db)
js
// Herkesin gördüğü veri — katalog, içerik, gelen talepler.
const rows = await devany.db.list('appointments');
// Yeni kayıt (id vermezsen oluşturur, verirsen günceller)
const saved = await devany.db.put('appointments', {
name: 'Ayşe Yılmaz',
phone: '05xx',
at: '2026-08-01T14:00',
status: 'pending',
});
await devany.db.remove('appointments', saved.id);Records read both flat and via .doc: rec.name and rec.doc.name return the same value.
Per-user data (devany.user)
js
// Giriş yapmış kullanıcının KENDİ verisi — başkası göremez.
if (!devany.auth.isSignedIn()) return showLogin();
await devany.user.set('workouts', { date: '2026-08-01', reps: 30 });
const mine = await devany.user.list('workouts');
const one = await devany.user.get('workouts', id); // yoksa null
await devany.user.remove('workouts', id);Throws 'not_signed_in' when there is no session — gate the call with isSignedIn() first.
Two stores, which when?
| devany.db | devany.user | |
|---|---|---|
| Scope | The whole app | One user |
| Needs an account | ||
| Document cap | 20K chars | 20K chars |
| Collection cap | — | 500 records |
| Typical use | Catalog, orders | Personal tracking |
Key takeaways
- devany.db is shared, devany.user is per-person; the API shape is identical.
- The user store needs a session or throws 'not_signed_in'.
- Images go to file storage; the record keeps only the URL.
Related topics
Still stuck? Ask the assistant in the corner, or browse the FAQ.