@instantdb/core
Version:
Instant's core local abstraction
73 lines • 2.59 kB
TypeScript
import { EntityDef, DataAttrDef, InstantSchemaDef, type EntitiesDef, type AttrsDefs, type EntitiesWithLinks, type LinksDef, type RoomsDef, type UnknownRooms } from './schemaTypes.ts';
/**
* @deprecated
* `i.graph` is deprecated. Use `i.schema` instead.
*
* @example
* // Before
* i.graph(entities, links).withRoomSchema<RoomType>();
*
* // After
* i.schema({ entities, links, rooms })
*
* @see
* https://instantdb.com/docs/schema
*/
declare function graph<EntitiesWithoutLinks extends EntitiesDef, const Links extends LinksDef<EntitiesWithoutLinks>>(entities: EntitiesWithoutLinks, links: Links): InstantSchemaDef<EntitiesWithLinks<EntitiesWithoutLinks, Links>, LinksDef<any>, UnknownRooms>;
/**
* Creates an entity definition, to be used in conjunction with `i.graph`.
*
* @see https://instantdb.com/docs/schema
* @example
* {
* posts: i.entity({
* title: i.string(),
* body: i.string(),
* }),
* comments: i.entity({
* body: i.string(),
* })
* }
*/
declare function entity<Attrs extends AttrsDefs>(attrs: Attrs): EntityDef<Attrs, {}, void>;
declare function string<StringEnum extends string = string>(): DataAttrDef<StringEnum, true, false>;
declare function number(): DataAttrDef<number, true, false>;
declare function boolean(): DataAttrDef<boolean, true, false>;
declare function date(): DataAttrDef<string | number, true, false>;
declare function json<T = any>(): DataAttrDef<T, true, false>;
declare function any(): DataAttrDef<any, true, false>;
/**
* Lets you define a schema for your database.
*
* You can define entities, links between entities, and if you use
* presence, you can define rooms.
*
* You can push this schema to your database with the CLI,
* or use it inside `init`, to get typesafety and autocompletion.
*
* @see https://instantdb.com/docs/schema
* @example
* i.schema({
* entities: { },
* links: { },
* rooms: { }
* });
*/
declare function schema<EntitiesWithoutLinks extends EntitiesDef, const Links extends LinksDef<EntitiesWithoutLinks>, Rooms extends RoomsDef>({ entities, links, rooms, }: {
entities: EntitiesWithoutLinks;
links?: Links;
rooms?: Rooms;
}): InstantSchemaDef<EntitiesWithLinks<EntitiesWithoutLinks, Links>, LinksDef<any>, Rooms>;
export declare const i: {
graph: typeof graph;
schema: typeof schema;
entity: typeof entity;
string: typeof string;
number: typeof number;
boolean: typeof boolean;
date: typeof date;
json: typeof json;
any: typeof any;
};
export {};
//# sourceMappingURL=schema.d.ts.map