Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. async function createMyConnection() {
  2.  
  3. await createConnection({
  4. driver: {
  5. type: "postgres",
  6. host: "myHost",
  7. port: 5432,
  8. username: "myUsername",
  9. password: "mypassword",
  10. database: "mydatabase"
  11. },
  12. entities: [
  13. Photo, PhotoMetadata, Author, Album
  14. ],
  15. autoSchemaSync: true,
  16. });
  17.  
  18. let connection = getConnectionManager().get();
  19.  
  20. let photo = new Photo();
  21. photo.name = "Me and Bears";
  22. photo.description = "I am near polar bear222";
  23. photo.fileName = "photo-with-bears.jpg";
  24. photo.views = 1;
  25. photo.isPublished = true;
  26.  
  27. let metadata = new PhotoMetadata();
  28. metadata.height = 640;
  29. metadata.width = 480;
  30. metadata.compressed = true;
  31. metadata.comment = "cybershoot";
  32. metadata.orientation = "portait";
  33.  
  34. photo.metadata = metadata;
  35.  
  36. let author = new Author();
  37. author.name = 'Kaveh';
  38.  
  39. photo.author = author;
  40.  
  41. let album = new Album();
  42. album.name = 'MyAlbum1';
  43.  
  44. let album2 = new Album();
  45. album.name = 'MyAlbum2';
  46.  
  47. photo.albums = [album, album2];
  48.  
  49. connection.entityManager
  50. .persist(photo)
  51. .then(p => {
  52. console.log("Photo has been saved");
  53. connection.close();
  54. })
  55. .catch(() => {
  56. connection.close();
  57. });
  58. }
  59.  
  60. createMyConnection();
  61.  
  62. (node:540) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): error: syntax error at or near ")"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement