darkrishabh / react-native-db-models

React native Library for creating Local DB models
MIT License
173 stars 31 forks source link

Not issue, suggestion #7

Open getreup opened 9 years ago

getreup commented 9 years ago

Hey darkrishabh,

No issue, just wanted to suggest maybe making a lazy table creator in your DB.js, like so:

var RNDBModel = require('react-native-db-models')
var DB = {
    table : function(tableName)
    {
      if( typeof DB[tableName] === 'undefined' ) DB[tableName] = new RNDBModel.create_db(tableName);

      return DB[tableName];
    },
}
module.exports = DB

Is there a foreseeable issue with this method?

The advantage is that if you have dynamic code that may add new data structures at any time, you can let that happen.

Thanks,

Kelsey

darkrishabh commented 8 years ago

Its funny, because I currently have an extended API called initDB that I have been using personally which does the similar task. I will integrate it soon. Thanks @KelseyRegan