xiaohongshu
xiaohongshu
dojo-entities
Use when querying, fetching, or subscribing to game entities in dojo.js. Triggers: entity query, fetch entities, useModel, useEntityQuery, ToriiQueryBuilder, subscribe entities, getEntities, entity subscription, model data
Full skill instructions
Use this skill when:
Build type-safe queries for entities:
import { ToriiQueryBuilder, KeysClause, MemberClause } from "@dojoengine/sdk";
// Basic query with limit
const query = new ToriiQueryBuilder<typeof schema>()
.withLimit(100)
.build();
// Query with clause filter
const query = new ToriiQueryBuilder<typeof schema>()
.withClause(
KeysClause(["game-Player"], [playerAddress], "VariableLen").build()
)
.withLimit(50)
.build();
// Query with ordering
const query = new ToriiQueryBuilder<typeof schema>()
.addOrderBy("game-Player.score", "Desc")
.withLimit(10)
.build();
// Query specific models
const query = new ToriiQueryBuilder<typeof schema>()
.addEntityModel("game-Player")
.addEntityModel("game-Position")
.withLimit(100)
.build();
const query = new ToriiQueryBuilder<typeof schema>()
.withLimit(50) // Max results
.withCursor(nextCursor) // Pagination cursor
.withDirection("Forward") // "Forward" | "Backward"
.build();
// Keys clause - filter by entity keys
KeysClause(["namespace-Model"], [key1, key2], "VariableLen")
// Member clause - filter by field value
MemberClause("namespace-Model", "fieldName", "Eq", value)
// Composite clause - combine clauses
CompositeClause("And", [clause1, clause2])
const { sdk } = useDojoSDK();
// One-time fetch
const result = await sdk.getEntities({
query: new ToriiQueryBuilder<typeof schema>()
.withClause(clause)
.withLimit(100)
});
// Access results
result.items.forEach(entity => {
console.log(entity.entityId, entity.models);
});
// Pagination
if (result.next_cursor) {
const nextPage = await sdk.getEntities({
query: new ToriiQueryBuilder<typeof schema>()
.withCursor(result.next_cursor)
.withLimit(100)
});
}
const { sdk } = useDojoSDK();
const [initialData, subscription] = await sdk.subscribeEntityQuery({
query: new ToriiQueryBuilder<typeof schema>()
.withClause(clause)
.withLimit(100),
callback: ({ data, error }) => {
if (error) {
console.error("Subscription error:", error);
return;
}
// Handle real-time updates
console.log("Entity updated:", data);
}
});
// Clean up subscription
subscription.cancel();
import { useModel } from "@dojoengine/sdk/react";
function PlayerStats({ entityId }) {
// Format: "namespace-ModelName"
const player = useModel(entityId, "game-Player");
if (!player) return <div>Loading...</div>;
return <div>Score: {player.score}</div>;
}
import { useModels } from "@dojoengine/sdk/react";
function Leaderboard() {
const players = useModels("game-Player");
return (
<ul>
{Object.entries(players).map(([entityId, player]) => (
<li key={entityId}>{player?.name}: {player?.score}</li>
))}
</ul>
);
}
import { useHistoricalModel } from "@dojoengine/sdk/react";
function PlayerHistory({ entityId }) {
const history = useHistoricalModel(entityId, "game-Player");
return (
<ul>
{history.map((snapshot, i) => (
<li key={i}>Score: {snapshot.models.game.Player.score}</li>
))}
</ul>
);
}
import { getEntityIdFromKeys } from "@dojoengine/utils";
// Generate entity ID from keys
const entityId = getEntityIdFromKeys([
BigInt(playerAddress),
BigInt(gameId)
]);
"namespace-ModelName" format (hyphen-separated)entityId.toString() if neededxiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience