Skip to main content

Sub-Documents

The model service supports CRUD operations against sub-documents.

import egoseAdapter from '@egose/adapter-js';

const adapter = egoseAdapter.createAdapter({ baseURL: 'http://127.0.0.1:3000/api' });

interface Status {
name: string;
active: boolean;
}

interface User {
name: string;
statusHistory: Status[];
[key: string]: any;
}

const userService = adapter.createModelService<User>({ modelName: 'User', basePath: 'users' });
const sub = services.userService.id('79c8c567b05e986509d55733a').subs('statusHistory');