diff options
author | Nate Sesti <sestinj@gmail.com> | 2023-05-23 23:45:12 -0400 |
---|---|---|
committer | Nate Sesti <sestinj@gmail.com> | 2023-05-23 23:45:12 -0400 |
commit | f53768612b1e2268697b5444e502032ef9f3fb3c (patch) | |
tree | 4ed49b73e6bd3c2f8fceffa9643973033f87af95 /extension/examples/MyProject/src/index.ts | |
download | sncontinue-f53768612b1e2268697b5444e502032ef9f3fb3c.tar.gz sncontinue-f53768612b1e2268697b5444e502032ef9f3fb3c.tar.bz2 sncontinue-f53768612b1e2268697b5444e502032ef9f3fb3c.zip |
copying from old repo
Diffstat (limited to 'extension/examples/MyProject/src/index.ts')
-rw-r--r-- | extension/examples/MyProject/src/index.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/extension/examples/MyProject/src/index.ts b/extension/examples/MyProject/src/index.ts new file mode 100644 index 00000000..9ffd7282 --- /dev/null +++ b/extension/examples/MyProject/src/index.ts @@ -0,0 +1,20 @@ +import { AppDataSource } from "./data-source" +import { User } from "./entity/User" + +AppDataSource.initialize().then(async () => { + + console.log("Inserting a new user into the database...") + const user = new User() + user.firstName = "Timber" + user.lastName = "Saw" + user.age = 25 + await AppDataSource.manager.save(user) + console.log("Saved a new user with id: " + user.id) + + console.log("Loading users from the database...") + const users = await AppDataSource.manager.find(User) + console.log("Loaded users: ", users) + + console.log("Here you can setup and run express / fastify / any other framework.") + +}).catch(error => console.log(error)) |