@graphprotocol/graph-cli
Version:
CLI for building for and deploying to The Graph
45 lines (38 loc) • 986 B
text/typescript
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
import {
TypedMap,
Entity,
Value,
ValueKind,
store,
Bytes,
BigInt,
BigDecimal
} from "@graphprotocol/graph-ts";
export class MyEntity extends Entity {
constructor(id: string) {
super();
this.set("id", Value.fromString(id));
}
save(): void {
let id = this.get("id");
assert(id != null, "Cannot save MyEntity entity without an ID");
if (id) {
assert(
id.kind == ValueKind.STRING,
`Entities of type MyEntity must have an ID of type String but the id '${id.displayData()}' is of type ${id.displayKind()}`
);
store.set("MyEntity", id.toString(), this);
}
}
static load(id: string): MyEntity | null {
return changetype<MyEntity | null>(store.get("MyEntity", id));
}
get id(): string {
let value = this.get("id");
return value!.toString();
}
set id(value: string) {
this.set("id", Value.fromString(value));
}
}