GithubHelp home page GithubHelp logo

Comments (3)

bahmutov avatar bahmutov commented on May 25, 2024

from console.table.

sp-suresh avatar sp-suresh commented on May 25, 2024

Well, It's resolved by converting it to plain js object by using mongoose's lean

Below is the modified code:

const cTable = require('console.table');
const mongoose = require('mongoose');
mongoose.connect('mongodb:/host', {
	auth: {
		user: 'unm',
		password: 'pwd'
	}
});

const pairNm = 'BTC-INR-tx'



const pairModel = mongoose.model(pairNm, {}, pairNm);

pairModel.find({}, {_id: 0, trans_id: 1,
    fill_qty: 1,
    fill_price: 1,
    fill_flags: 1,
    currencyPair: 1,
    lastModifiedDate: 1}).limit(10).lean().exec().then((d) => {
	// console.log(d);
	console.table('d', d);
});

Which results in beautiful tabled response:

d
---------------------------------------------------------------------------
trans_id  fill_qty   fill_price  fill_flags  currencyPair  lastModifiedDate
--------  ---------  ----------  ----------  ------------  ----------------
382       10000000   712500      3           BTC-INR       1521712287144   
384       5000000    711800      2           BTC-INR       1521714892456   
                                                                           
392       10000000   711200      1           BTC-INR       1521787237696   
393       10000000   711200      3           BTC-INR       1521787298539   
394       21168      715000      2           BTC-INR       1521790941289   
395       978832     715000      3           BTC-INR       1521791070426   
399       100000000  716000      3           BTC-INR       1521798458247   
400       22510000   710000      2           BTC-INR       1521800843473   
400       77490000   709000      1           BTC-INR       1521800843474  

from console.table.

sp-suresh avatar sp-suresh commented on May 25, 2024

Mongoose response is not a plain js object, It has to be converted first before converting it to table structure.

from console.table.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.