Best way to transport large data between controller and view

58 views
Skip to first unread message

Julien

unread,
Apr 15, 2014, 7:31:16 AM4/15/14
to tot...@googlegroups.com
Hi,

Have you an idea to transport large (0 to 5000 and more) data between controller and view ?

Do you use websocket ? json file ? or model ?
I have a preference for json file.
(Example)

Julien

Peter Širka

unread,
Apr 15, 2014, 7:38:49 AM4/15/14
to tot...@googlegroups.com
Please describe more about the data.
Thanks.

Julien

unread,
Apr 15, 2014, 7:40:45 AM4/15/14
to tot...@googlegroups.com
Hi,

I have two functions for the transport data and it works. But i would like to replace the model.data by json file.
 If i created json file in sendata(function (featureCollection) {  i have a server error: TIME OUT.

WHY ?

Thank you


function sendata(callback) {

    var connString = 'tcp://postgres:test@localhost/postgres';

    pg.connect(connString, function(err, client) {
        var sql = 'select * FROM table_example';
        client.query(sql, function(err, result) {
            callback(result);
        });
    });
}

function view_detail(id) {

    var self = this;
    if(id == 'new')
        self.view404('Blog not found ->');

    var Project = self.model('project').Project;
    Project.find({ _id: id }).populate('project').limit(1).exec(function(err, doc) {

        if (err) {
            self.view500(err);
            return;
        }

        if (doc.length === 0) {
            self.view404('Blog not found ->' + id);
            return;
        }

        var model = doc[0];
        Project.find({_id: id}).populate('project').sort({ 'created': -1 }).exec(function(err, rows) {
            sendata(function (featureCollection) { 
                model.data = featureCollection
                model.similar = rows;
                self.view('detail', model);
            });
            
        });
    });
}

Julien

unread,
Apr 15, 2014, 7:58:55 AM4/15/14
to tot...@googlegroups.com
The data are dynamics and it's very hard to explain to you the description.

For example: The client is loading data to database and the system (totaljs) visualize the data.
The client can use and modify the data in realtime for the collaboration.

Peter Širka

unread,
Apr 15, 2014, 8:01:47 AM4/15/14
to tot...@googlegroups.com
Project.find({_id: id}).populate('project').sort({ 'created': -1 }).exec(function(err, rows) {


   
// HERE
    console
.log('Project.find -->', err);

    sendata
(function(featureCollection) {

        model
.data = featureCollection
        model
.similar = rows;
       
self.view('detail', model);
   
});
});

function sendata(callback) {
   
var connString = 'tcp://postgres:test@localhost/postgres';
    pg
.connect(connString, function(err, client) {


       
// HERE
        console
.log('sendata ->', client);


       
var sql = 'select * FROM table_example';
        client
.query(sql, function(err, result) {

            console
.log('sendata -> client.query ->', err);

           
// HERE
            callback
(result);
       
});
   
});
}

And watch the console. Timeout is executed when is not returned a view/json/etc. or operation takes a long time (try to remove timeout ... framework.route('route', { timeout: 0 }, action).

Give me a feedback.
Thanks.

Julien

unread,
Apr 15, 2014, 8:12:44 AM4/15/14
to tot...@googlegroups.com
I try the solution tonight.
Thank you Peter for your support. 

Julien

unread,
Apr 15, 2014, 7:45:28 PM4/15/14
to tot...@googlegroups.com
Ok, i modified the code but i have a serious problem:

     { type: 'Feature', geometry: [Object] },
     { type: 'Feature', geometry: [Object] } ] }

The creation file is finished and the process crashed

FATAL ERROR: JS Allocation failed - process out of memory

Process finished with exit code 134

Peter Širka

unread,
Apr 16, 2014, 3:26:40 AM4/16/14
to tot...@googlegroups.com
Where did you get this data? From webservice or ...?
Reply all
Reply to author
Forward
0 new messages