Simple decorator for caching getters on first access.
npm install decorator-cache-getter --save
import { cache } from "decorator-cache-getter";
class User {
@cache
get friends() {
return sql("SELECT * FROM users WHERE ...")
}
}
const user = new User()
const friends = await user.friends;
MIT