First, add the property to the class
import { Item } from '@rpgjs/database'
@Item({
name: 'CustomItem'
})
export class CustomItem {
custom: number = 200
}
Then, on the map, we need to extend the scheme to incorporate the new property
import { RpgMap, MapData, RpgPlayer } from '@rpgjs/server'
const itemsSchema = RpgPlayer.schemas.items[0]
@MapData({
id: 'cave',
file: require('./tmx/cave.tmx'),
syncSchema: {
users: [
{
...RpgPlayer.schemas,
items: [{
...itemsSchema,
item: {
...itemsSchema.item,
custom: Number
}
}]
}
]
}
})
export class CaveMap extends RpgMap {}
https://docs.rpgjs.dev/api/MapData.html#syncschema
The use of syncSchema
becomes complex in some situations, I think about its simplification