Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

typeorm sqlite Using Repositories

import {createConnection} from "typeorm";
import {Photo} from "./entity/Photo";
 
createConnection(/*...*/).then(async connection => {
 
    let photo = new Photo();
    photo.name = "Me and Bears";
    photo.description = "I am near polar bears";
    photo.filename = "photo-with-bears.jpg";
    photo.views = 1;
    photo.isPublished = true;
 
    let photoRepository = connection.getRepository(Photo);
 
    await photoRepository.save(photo);
    console.log("Photo has been saved");
 
    let savedPhotos = await photoRepository.find();
    console.log("All photos from the db: ", savedPhotos);
 
}).catch(error => console.log(error));
Source by www.npmjs.com #
 
PREVIOUS NEXT
Tagged: #typeorm #sqlite #Using #Repositories
ADD COMMENT
Topic
Name
6+8 =