-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
hi ,
the first time i reload the app (ctrl+m ==> reload )is work perfect but when i exit the app and again run it the warning popup
i wanna close the connection but i don't no how :(
this is my code in react-native App
export default class App extends Component {
constructor(props) {
super(props);
this.state = {
savedPost: false, progress: 'Post is being saved', loadedPost: [],
textDescription: '',
title: '',
category: '',
birthDate: '1998-8-02',
author: ''
};
this.runDemo();
}
connect() {
return createConnection({
type: 'react-native',
database: 'test',
location: 'default',
logging: ['error', 'query', 'schema'],
synchronize: true,
entities: [
Author,
Category,
Post
]
});``
async runDemo() {
try {
// SQLite.openDatabase({ name: 'my.db', location: 'Library' }, this.successCB, this.errorCB);
await this.connect();
const category1 = new Category();
category1.name = "TypeScript";
const category2 = new Category();
category2.name = "Programming";
const author = new Author();
author.name = "Person";
const post = new Post();
post.title = "Control flow based type analysis";
post.text = "TypeScript 2.0 implements a control flow-based type analysis for local variables and parameters.";
post.categories = [category1, category2];
post.author = author;
const postRepository = getRepository(Post);
// await postRepository.save(post);
console.log("Post has been saved");
this.setState({
progress: "Post has been saved"
});
const loadedPost = await postRepository.find({ id: Between('10', '12') });
// createQueryBuilder('post')
// .innerJoinAndSelect("post.author", "author")
// .innerJoinAndSelect('post.categories', 'categories')
// .where('post.id = :id', { id: post.id })
// .getOne();
if (loadedPost) {
console.log("Post has been loaded: ", loadedPost);
this.setState({
loadedPost: loadedPost
});
}
} catch (err) {
console.log(err)
}
Metadata
Metadata
Assignees
Labels
No labels