0

What are possible values if a variable inside an interface is typed as Uint8Array?

typeorm/src/driver/sqljs/SqljsConnectionOptions.ts https://github.com/typeorm/typeorm/blob/master/src/driver/sqljs/SqljsConnectionOptions.ts

/**
 * Sql.js-specific connection options.
 */
export interface SqljsConnectionOptions extends BaseConnectionOptions {

    /**
     * A Uint8Array that gets imported when the connection is opened.
     */
    readonly database?: Uint8Array;
}

If already read MDN's article on Uint8Array, but it did not help.

EDIT: As you can see, there is a database name required. Intuitivly I would past in the name of my database, but this is a string. So how does a database in Uint8Array format look like?

1
  • What do you mean, it did not help? A variable declared as Uint8Array can have a value of Uint8Array, obviously. E.g. new Uint8Array(10) is a value it could have. What specifically is the problem you are having? Commented Feb 23, 2018 at 19:55

2 Answers 2

2

It is not a database name. It is a database. Reading up on what sql.js is will show you it is SQLite compiled into JavaScript through Emscripten, with an in-memory store. By default, it gives you a blank database, which will get forgotten when you stop using it; but you have an option of importing it from, or exporting it to, an Uint8Array, which is literally the byte-by-byte contents of your SQLite database file. Look at sql.js readme to see many examples of how to get the database array (from upload, from XHR, from Node.js reading of a file...).

Sign up to request clarification or add additional context in comments.

4 Comments

This wasn't really clear for me. After reading more, I've understood the principles of Unit8Array, but please, this is not cristal clear and unintuitive.
What specifically wasn't clear? Do you have a SQLite database you wish to import? If you do, where is it? Are we talking clientside or serverside? The answer is as clear as the question lets it be; besides, the examples on the linked README address most scenarios.
I think you have missunderstood me, I am totally fine with your answer. I meant the reading for instance on MDN etc. You'r answer finally clearified everthing ;)
Ah I see. :) Cheers then!
1

Type of data is gonna be an array of 8-bit unsigned integer.

If you're not familiar with it, this link explains well http://ctp.mkprog.com/en/ctp/unsigned_8bit_integer/

"8-bit unsigned integer type is used to store only pozitiv whole number. 8-bit unsigned integer and his value range: from 0 to 255."

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.