samualtnorman / hackmud-script-manager

Script manager for game hackmud, with minification, TypeScript support, and player script type definition generation.
https://www.npmjs.com/package/hackmud-script-manager
MIT License
11 stars 4 forks source link

Add better typings to `$db` functions. #203

Closed Longboyy closed 3 months ago

Longboyy commented 4 months ago

This PR improves upon the existing $db typings, providing type safety throughout the process:

type MySchema = {
    _id: "my_schema",
    someData: number[]
}

$db.us<MySchema>({
    _id: "my_schema"
}, {
    $setOnInsert: {
        someData: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    }
});
samualtnorman commented 3 months ago

Thank you for beginning work on this. I have taken what you've done so far and and kept adding to and tweaking it over at the Longboyy/db-types branch.