mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
26 lines
501 B
TypeScript
26 lines
501 B
TypeScript
import Dexie from "dexie";
|
|
|
|
interface IFriend {
|
|
id?: number,
|
|
name?: string,
|
|
age?: number
|
|
}
|
|
|
|
class MyDB extends Dexie {
|
|
friends: Dexie.Table<IFriend, number>;
|
|
constructor() {
|
|
super("MyDB");
|
|
this.version(1).stores({
|
|
friends: "++id,name,age"
|
|
});
|
|
}
|
|
}
|
|
|
|
var db = new MyDB();
|
|
|
|
db.friends.add({name: "Kalle", age: 23}).then(()=>{
|
|
db.friends.where('age').below(30).count(count => {
|
|
console.log("Num yound friends: " + count);
|
|
});
|
|
});
|