Giter Club home page Giter Club logo

spanner-terraform-example's People

Contributors

rohan-searce avatar vigneshsdev avatar yogirk avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

spanner-terraform-example's Issues

General remarks

@vignesh-sdev @rohan-searce @yogirk

I had a couple of general remarks on the current application setup, but as those files are currently not touched by any of the open PRs, it's a little bit difficult to add comments on it. I've therefore summarized it here in an issue.

Please feel free to let me know if something is not clear, or if I've misunderstood anything.

Data Model

The data model of the application uses FLOAT64 for several properties that would be better represented by other data types:

  • Number of shares, both of a company as well as trade volumes, are always integers. It would be better to use INT64 instead of FLOAT64.
  • Share prices are normally specified as fixed-precision numbers. It would therefore be better to use NUMERIC instead of FLOAT64 for these properties.

See

"CREATE TABLE companyStocks (companyStockId STRING(36) NOT NULL, companyId STRING(36) NOT NULL, companyShortCode STRING(10), exchangeName STRING(50), exchangeMic STRING(50), timezone STRING(50), shares FLOAT64, requestId STRING(15), open FLOAT64, volume FLOAT64, currentValue FLOAT64, date FLOAT64, close FLOAT64, dayHigh FLOAT64, dayLow FLOAT64, adjHigh FLOAT64, adjLow FLOAT64, adjClose FLOAT64, adjOpen FLOAT64, adjVolume FLOAT64, timestamp TIMESTAMP NOT NULL OPTIONS (allow_commit_timestamp = true), ) PRIMARY KEY(companyStockId)",

Executing queries

There are multiple queries in the application that do manual conversion of the query results to JSON. That can be done automatically by the Spanner client library by setting the json: true option in the query.

For example the function here could therefore be simplified to this:

Users.prototype.getAllUsers = async function () {
    try {
        const query = {
            sql: 'select * from company',
            json: true,
        };
        return await database.run(query);
    } catch (err) {
        throw ("error in getAllUsers function", err)
    }
}

You should also consider adding some kind of protection against out-of-memory problems in a query like this. Selecting all rows from a table without a WHERE or LIMIT clause could bring down your entire application if the table grows beyond the size that you expected.

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.