GithubHelp home page GithubHelp logo

fauna / fauna-js Goto Github PK

View Code? Open in Web Editor NEW
35.0 9.0 8.0 1.1 MB

Javascript driver for Fauna v10

Home Page: https://fauna.com

License: Other

Shell 1.07% TypeScript 98.55% JavaScript 0.38%
fauna faunadb serverless typescript database javascript client driver nosql nosql-database

fauna-js's Introduction

The Official JavaScript Driver for Fauna.

npm Version License

This driver can only be used with FQL v10, and is not compatible with earlier versions of FQL. To query your databases with earlier API versions, see the faunadb package.

See the Fauna Documentation for additional information how to configure and query your databases.

Table of Contents

Supported runtimes

Server-side

Node.js - Current and active LTS versions:

  • Current - v20
  • LTS - v18

Cloud providers

  • Cloudflare Workers
  • AWS Lambda
  • Netlify
  • Vercel

Browsers

Stable versions of:

  • Chrome 69+
  • Firefox 62+
  • Safari 12.1+
  • Edge 79+

Install

The driver is available on npm. You can install it using your preferred package manager. For example:

npm install fauna

Browsers can import the driver using a CDN link:

<script type="module">
  import * as fauna from "https://cdn.jsdelivr.net/npm/fauna@latest/dist/browser/index.js";
</script>

Usage

By default, the driver's Client instance authenticates with Fauna using an access token in the FAUNA_SECRET environment variable. If needed, you can pass the token to the client using the secret argument instead.

import { Client, fql, FaunaError } from "fauna";
// Use `require` for CommonJS:
// const { Client, fql, FaunaError } = require('fauna');

const client = new Client();
// To configure your client:
// const client = new Client({
//   secret: YOUR_FAUNA_SECRET,
// });

try {
  // Build a query using the `fql` method
  const collectionQuery = fql`Collection.create({ name: "Dogs" })`;
  // Run the query
  const collectionResponse = await client.query(collectionQuery);

  // Declare a var for app data
  const dog = { name: "Scout" };

  // Build a query using the var
  const documentQuery = fql`
    Dogs.create(${dog}) {
      id,
      ts,
      name
    }
  `;

  // Run the query
  const response = await client.query(documentQuery);
  console.log(response);
} catch (error) {
  if (error instanceof FaunaError) {
    console.log(error);
  }
} finally {
  // Clean up any remaining resources
  client.close();
}

Write FQL queries

The fql function is your gateway to building safe, reuseable Fauna queries.

It allows you compose queries from sub-queries and variables native to your program. Variables passed in are treated as unexecutable values in Fauna's API - preventing security issues like injection attacks.

For example:

import { Client, fql } from "fauna";

const client = new Client();

// Variables can be used as arguments in an FQL query
const collectionName = "Pets";

// Build a reusable sub-query to determine if a collection exists
const collectionExists = (name) => fql`Collection.byName(${name}) != null`;

// Build query that uses the previous var and sub-query
const upsertCollectionQuery = fql`
  if (${collectionExists(collectionName)}) {
    "Collection already exists"
  } else {
    Collection.create({ name: ${collectionName} })
    "Collection created"
  }
`;

// Run the query
const response = await client.query(upsertCollectionQuery);
console.log(response.data);

client.close();

This has several advantages:

  • You can use fql to build a library of subqueries applicable to your domain - and combinable in whatever way you need
  • Injection attacks are not possible if you pass input variables into the interpolated (`${interpoloated_argument}`) parts of the query.
  • The driver speaks "pure" FQL - you can try out some FQL queries on the dashboard's terminal and paste it directly into your app like fql`copied from terminal...` and the query will work as is.

Typescript support

With TypeScript, you can apply a type parameter to your result.

import { fql, Client, type QuerySuccess } from "fauna";

const client = new Client();

type User = {
  name: string;
  email: string;
};

const query = fql`{
  name: "Alice",
  email: "[email protected]",
}`;

const response: QuerySuccess<User> = await client.query<User>(query);
const user_doc: User = response.data;

console.assert(user_doc.name === "Alice");
console.assert(user_doc.email === "[email protected]");

client.close();

Query options

Options are available to configure queries on each request. These override any default query options in the client configuration.

import { fql, Client, type QueryOptions } from "fauna";

const client = new Client();

const options: QueryOptions = {
  arguments: { name: "Alice" },
  format: "tagged",
  long_type: "number",
  linearized: false,
  max_contention_retries: 5,
  query_tags: { name: "readme_query" },
  query_timeout_ms: 60_000,
  traceparent: "00-750efa5fb6a131eb2cf4db39f28366cb-000000000000000b-00",
  typecheck: true,
};

const response = await client.query(fql`"Hello, #{name}!"`, options);
console.log(response.data)

client.close();

Query statistics

Query statistics are returned with successful query responses and errors of the ServiceError type.

import {
  fql,
  Client,
  ServiceError,
  type QueryInfo,
  type QueryStats,
  type QuerySuccess,
} from "fauna";

const client = new Client();

try {
  const response: QuerySuccess<string> = await client.query<string>(
    fql`"Hello world"`
  );
  const stats: QueryStats | undefined = response.stats;
  console.log(stats);
} catch (error: any) {
  if (error instanceof ServiceError) {
    const info: QueryInfo = error.queryInfo;
    const stats: QueryStats | undefined = info.stats;
  }
}

Example output:

{
  compute_ops: 1,
  read_ops: 0,
  write_ops: 0,
  query_time_ms: 15,
  storage_bytes_read: 0,
  storage_bytes_write: 0,
  contention_retries: 0
}

Pagination

Use the Client.paginate() method to iterate sets that contain more than one page of results.

Client.paginate() accepts the same query options as Client.query().

Change the default items per page using FQL's <set>.pageSize() method.

import { fql, Client, type SetIterator, type QueryValue } from "fauna";

const client = new Client();

// Adjust `pageSize()` size as needed.
const query = fql`
  Product
    .byName("limes")
    .pageSize(60) { description }`;

const options = {
  query_timeout_ms: 60_000,
};

const pages: SetIterator<QueryValue> = client.paginate(query, options);

for await (const products of pages) {
  for (const product of products) {
    console.log(product)
  }
}

client.close();

Event Streaming (beta)

Event Streaming is currently available in the beta version of the driver:

Client configuration

The driver's Client instance comes with reasonable defaults that should be used in most cases. Yu can override these defaults if needed.

In addition to configuring the client, you can also set default query options.

import { Client, endpoints, type ClientConfiguration } from "fauna";

const config: ClientConfiguration = {
  // Configure the client
  client_timeout_buffer_ms: 5000,
  endpoint: endpoints.default,
  fetch_keepalive: false,
  http2_max_streams: 100,
  http2_session_idle_ms: 5000,
  secret: YOUR_FAUNA_SECRET,

  // Set default query options
  format: "tagged",
  long_type: "number",
  linearized: false,
  max_attempts: 3,
  max_backoff: 20,
  max_contention_retries: 5,
  query_tags: { name: "readme query" },
  query_timeout_ms: 60_000,
  traceparent: "00-750efa5fb6a131eb2cf4db39f28366cb-000000000000000b-00",
  typecheck: true,
};

const client = new Client(config);

Environment variables

The driver will default to configuring your client with the values of the FAUNA_SECRET and FAUNA_ENDPOINT environment variable.

For example, if you set the following environment variables:

export FAUNA_SECRET=YOUR_FAUNA_SECRET
export FAUNA_ENDPOINT=https://db.fauna.com/

You can initalize the client with a default configuration:

const client = new Client();

Retry

Max attempts

The maximum number of times a query will be attempted if a retryable exception is thrown (ThrottlingError). Default 3, inclusive of the initial call. The retry strategy implemented is a simple exponential backoff.

To disable retries, pass max_attempts less than or equal to 1.

Max backoff

The maximum backoff in seconds to be observed between each retry. Default 20 seconds.

Timeouts

There are a few different timeout settings that can be configured; each comes with a default setting. We recommend that most applications simply stick to the defaults.

Query timeout

The query timeout is the time, in milliseconds, that Fauna will spend executing your query before aborting with a 503 Timeout error. If a query timeout occurs, the driver will throw an instance of ServiceTimeoutError.

The query timeout can be set using the ClientConfiguration.query_timeout_ms option. The default value if you do not provide one is 5000 ms (5 seconds).

const client = new Client({ query_timeout_ms: 20_000 });

The query timeout can also be set to a different value for each query using the QueryOptions.query_timeout_ms option. Doing so overrides the client configuration when performing this query.

const response = await client.query(myQuery, { query_timeout_ms: 20_000 });

Client timeout

The client timeout is the time, in milliseconds, that the client will wait for a network response before canceling the request. If a client timeout occurs, the driver will throw an instance of NetworkError.

The client timeout is always the query timeout plus an additional buffer. This ensures that the client always waits for at least as long Fauna could work on your query and account for network latency. The client timeout buffer is configured by setting the client_timeout_buffer_ms option. The default value for the buffer if you do not provide on is 5000 ms (5 seconds), therefore the default client timeout is 10000 ms (10 s) when considering the default query timeout.

const client = new Client({ client_timeout_buffer_ms: 6000 });

HTTP/2 session idle timeout

The HTTP/2 session idle timeout is the time, in milliseconds, that an HTTP/2 session will remain open after there is no more pending communication. Once the session idle time has elapsed the session is considered idle and the session is closed. Subsequent requests will create a new session; the session idle timeout does not result in an error.

Configure the HTTP/2 session idle timeout using the http2_session_idle_ms option. The default value if you do not provide one is 5000 ms (5 seconds).

This setting only applies to clients using HTTP/2 implementations; for example, the default client for Node.js runtimes.

const client = new Client({ http2_session_idle_ms: 6000 });

Note Your application process may continue executing after all requests are completed for the duration of the session idle timeout. To prevent this, it is recommended to call Client.close() once all requests are complete. It is not recommended to set http2_session_idle_ms to small values.

Warning Setting http2_session_idle_ms to small values can lead to a race condition where requests cannot be transmitted before the session is closed, yielding ERR_HTTP2_GOAWAY_SESSION errors.

Contributing

Any contributions are from the community are greatly appreciated!

If you have a suggestion that would make this better, please fork the repo and create a pull request. You may also simply open an issue. We provide templates, so please complete those to the best of your ability.

Don't forget to give the project a star! Thanks again!

Set up the repo

  1. Clone the repository; e.g. gh repo clone fauna/fauna-js if you use the GitHub CLI
  2. Install dependencies via yarn install

Run tests

  1. Start a docker desktop or other docker platform.
  2. Run yarn test. This will start local fauna containers, verify they're up and run all tests.

Lint your code

Linting runs automatically on each commit.

If you wish to run on-demand run yarn lint.

License

Distributed under the MPL 2.0 License. See LICENSE for more information.

fauna-js's People

Contributors

adambollen avatar breinero avatar clbray avatar cleve-fauna avatar cynicaljoy avatar dependabot[bot] avatar fauna-chase avatar jrodewig avatar macmv avatar notrab avatar pnwpedro avatar ptpaterson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fauna-js's Issues

Next dev hot reload warnings

When using next dev locally to develop, run into the following chatty warning (1000 warning logs per minute):

hot-dev-client.js:85 ./node_modules/fauna/dist/browser/index.js
Critical dependency: require function is used in a way in which dep endencies cannot be statically extracted

Does not work with Fauna Dev, unknown format error

I attempted to connect to Fauna locally (using Fauna Dev) with fauna-js instead of faunadb-js, but encountered a format error.

Current Behavior

# Shell
% nc -vz localhost 8443
Connection to localhost port 8443 [tcp/pcsync-https] succeeded!
// main.ts
import { Client, endpoints, fql } from "fauna";

const client = new Client({ secret: "secret", endpoint: endpoints.local });
const query = fql`123`;
await client.query(query);

The following error has occurred.

ProtocolError: Response is in an unkown format: [object Object]

To begin with, does fauna-js support Fauna Dev? If there are any options I might have missed in the configuration, please let me know.

P.S. It seems that the spelling of unknown in the error message is incorrect.

message: `Response is in an unkown format: ${e.body}`,

Typescript compilation error in client.d.ts

Hello,

I've installed the library in a Ionic Project and when I'm importing fauna as per the documentation (import { Client, fql, FaunaError } from "fauna") I'm getting a typescript compilation error:

Error: node_modules/fauna/dist/client.d.ts:30:9 - error TS2380: The return type of a 'get' accessor must be assignable to its 'set' accessor type
[ng] Type 'undefined' is not assignable to type 'number'.
[ng]
[ng] 30 get lastTxnTs(): number | undefined;

Thanks a lot for your help :)

Support Vercel Edge environment

Hey folks, I'm developing an app using NextJS and I have a function that runs on the edge, and when I try to use the fauna client in this function, I get the following error:

Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

Import trace for requested module:
./node_modules/fauna/dist/browser/index.js
Error [ReferenceError]: navigator is not defined

I guess it is because it tries to access some browser feature that is not available ๐Ÿค”

To reproduce this you create a NextJS project and inside of the app folder, create a /api/route.ts with something like:

export const runtime = "edge";

export function GET() {
    const fauna = new Client({ ... })
    fauna.query(fql`[]`)
}

Sorry for not having too much more info to help with debug ๐Ÿ˜ž

FAUNA_ENDPOINT Environment Variable Is Not Honored

In the README, it states that the FAUNA_ENDPOINT environment variable can be used to override the default endpoint client configuration setting. However, this is not getting honored when set.

From what I see in the code, this just has not been implemented yet. There is an endpoint configuration that does have locahost settings, so this can be worked around with:

const client = process.env.FAUNA_ENDPOINT : 
  new Client({
    endpoint: endpoints.local
  }) ?
  new Client()

Repro Steps:
index.ts

import { Client } from 'fauna'
const client = new Client()
console.log(client.clientConfiguration)

Terminal

export FAUNA_ENDPOINT=http://localhost:8443
# transpile index.ts to javascript
node index.js

The output will show the default endpoint configuration (https://db.fauna.com/) instead of the environment setting (http://localhost:8443).

Errors in examples

Hey there, the arguments example isn't correct here

  1. in this line variable name must be defined which voids the purpose of arguments
client.query(fql`"Hello, ${name}!"`, options);

Experimenting I found that arguments will be available as they are inside the query, so the query should be like this:

const options: QueryOptions = {
  arguments: { name: "Alice" },
};

const response = await client.query(fql`"Hello, " + name + "!"`, options);

the result will be Hello, Alice!

  1. query_tags: { name: "readme query" }, - adding this line I get an error Invalid header 'x-query-tags': invalid tags
    I'm not sure about the use case of tags anyway.

FQL Objects with nested queries

It feels like something like this should work with this driver but it currently does not:

const enhancer = { field1: fql`collection.all().paginate(n)` }
query(fql`Object.assign(someDocument, ${enhancer})`)

I'm getting an empty object for field1

Error on client.close()

Hey folks, I created a utility function that runs Fauna queries + closes the connection when the query is done but I'm getting the following error:

- event compiled successfully in 177 ms (468 modules)
- error node_modules/fauna/dist/node/index.js (362:16) @ _NodeHTTP2Client.request
- error NetworkError: The network connection encountered a problem.

The code of the function is:

import { Client, Query, QueryValue } from "fauna";

export function runQuery<TQueryValue extends QueryValue>(query: Query) {
  const client = new Client({
    secret: process.env.FAUNA_SECRET_KEY,
  });

  try {
    return client.query<TQueryValue>(query);
  } finally {
    client.close();
  }
}

I'm guessing the issue is with the client.close() because when I remove it, the error is gone.

Response type for document doesn't include fields added by Fauna

For a query like:

const newUser = await faunaClient.query<TUser>(fql`
  Collection('collection_users').createData({
    email: ${emailNormalized},
    name: ${req.body.name},
    password_hash: ${hashPassword}
  })
`)

We get the data like:

Document {
  coll: Module { name: 'collection_users' },
  id: '389333327894544977',
  ts: TimeStub { isoString: '2024-02-10T09:07:25.340Z' },
  email: 'Redacted',
  name: 'Redacted',
  password_hash: '$argon2id$v=19$m=65536,t=3,p=4$7YqlCVX/rHuFoTae2ZwHLA$FkpZnC4FEJphv5ULkuz2TZrYcF8jZf/iv0AhTYXJSQg'
}

but my interface only includes:

export interface TUser {
  email : string
  id : string
  name : string
  password_hash : string
}

So if I try something like:

console.log(newUser.data.coll)

TypeScript complains:

Property coll does not exist on type TUser

This can be solved by adding these properties on my interface, but since these properties are added by Fauna, doesn't it make sense for the driver to handle this? This is a question and I could be wrong, so please consider this as a discussion or asking for advice.

Timeout during query merge

While debugging a non related component of my code I wanted to temporarily reduce the load on Fauna. Thus, I added a .take(1) to my query before a .paginate call. By doing so, I got a Timeout during query merge.

/tmp/node_modules/.pnpm/fauna@0.9.0/node_modules/fauna/src/client.ts:346
        return new ServiceTimeoutError(failure, httpStatus);
               ^
ServiceTimeoutError: Read timed out (Timeout during query merge.) java.util.concurrent.TimeoutException: Timeout during query merge.
    at _Client.getServiceError_fn (/tmp/node_modules/.pnpm/fauna@0.9.0/node_modules/fauna/src/client.ts:346:16)
    at _Client.getError_fn (/tmp/node_modules/.pnpm/fauna@0.9.0/node_modules/fauna/src/client.ts:279:16)
    at _Client.query_fn (/tmp/node_modules/.pnpm/fauna@0.9.0/node_modules/fauna/src/client.ts:416:15)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async fetchMessages (file:///tmp/data-science/fetch-data.ts:15:18)
    at async processCollection (file:///tmp/data-science/fetch-data.ts:35:20)
    at async file:///tmp/data-science/fetch-data.ts:69:1 {
  httpStatus: 503,
  code: 'time_out',
  queryInfo: {
    txn_ts: undefined,
    summary: undefined,
    query_tags: undefined,
    stats: undefined
  },
  constraint_failures: undefined
}

I could reproduce the error both in fauna 0.8.0 as in 0.9.0.
Here is the broken query:

fql`Message.all().where(
    m => m.service == ${service} && m.author.username != ${ignoredAuthor}
  ).take(1).paginate(9999)`

If I change it to take(10), it works. If I remove .take, it also works.

Error: The network connection encountered a problem

Description

I am facing errors that at first seem very generic (i.e. network connection) and not Fauna related. However, by Googleing the error we only find a single result and it's also thrown by Fauna:

oven-sh/bun#6204 - Network connection issue using FaunaDB JS SDK

Error

[Unhandled Rejection] NetworkError: Unexpected message handler failure: The network connection encountered a problem.
    at _NodeHTTP2Client.request (/node_modules/.pnpm/fauna@1.3.1/node_modules/fauna/src/http-client/node-http2-client.ts:94:17)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async _Client.query_fn (/node_modules/.pnpm/fauna@1.3.1/node_modules/fauna/src/client.ts:451:24)
    at async updateUser (file:///services/whatsapp-listener/store.ts:46:18)
    at async file:///services/whatsapp-listener/bot/index.ts:140:9
    at async Consumer.handleMessage (file:///packages/events/index.ts:37:19)
    at async Consumer.executeHandler (/node_modules/.pnpm/sqs-consumer@7.0.3/node_modules/sqs-consumer/dist/consumer.js:310:26)
    at async Consumer.processMessage (/node_modules/.pnpm/sqs-consumer@7.0.3/node_modules/sqs-consumer/dist/consumer.js:193:34)
    at async Promise.all (index 0)
    at async Consumer.handleSqsResponse (/node_modules/.pnpm/sqs-consumer@7.0.3/node_modules/sqs-consumer/dist/consumer.js:173:17) {
  [cause]: Error [ERR_HTTP2_ERROR]: Protocol error
      at __node_internal_captureLargerStackTrace (node:internal/errors:490:5)
      at new NghttpError (node:internal/http2/util:556:5)
      at Http2Session.onSessionInternalError (node:internal/http2/core:792:26) {
    code: 'ERR_HTTP2_ERROR',
    errno: -505
  }
}

Code

  import { Client, fql } from 'fauna'
  const client = new Client()

  const exp = fql`
    let doc = UserProfile.firstWhere(
      .identifier == "${id}"
    )
    
    if (doc == null) {
      UserProfile.create({
        identifier: "${id}",
        name: "${name}"
      })
    } else {
      doc!.update({
        name: "${name}"
      })
    }
    `

  const result = await client.query<UserProfile>(exp)

platform support

Axios hems us into a limited set of platforms. Re-evaluate http layer dependencies to support platforms including:

Cloudflare, Vercel Edge and Serverless functions, Web Assembly, the Deno runtime, AWS Lambda, Netlify Functions

[Feature request] Typegen/codegen

The DX in the fauna shell is really good, and it would be really great to be able to use it "as is" in js/ts. Actually, I see 2 possible ways:

  1. typegen like supabase. This way we can just import the types and pass them as the query generic
  2. codegen like prisma. All possible would be generated to be used just like in the fauna shell

2 seems more powerful but 1 seems easier

[Feature Request]: Have a utility function to parse the query result into valid JSON object

Issue
When trying to pass the fauna query result from the server to the FE or any client via API or server-side rendering it does not work out of the box when having complex fields in the result like a time object or an array of references.

PS: With FQL 10, I see the id field is directly returned from the document with its relationships as well โค๏ธ so maybe at this point, only the TimeStub object is not "JSON friendly"?

Suggestion
Have a serializeToJSON function to help with scenarios like the following:

export async function GET() {
  const fauna = new Client()
  const result = await fauna.query(fql`products.all(){ id, name, createdAt }`)
  return NextResponse.json(serializeToJSON(result))
}

Or even better if the result object could have a toJSON method.

NetworkError: The network connection encountered a problem - using Bun

Note: this may not be a Fauna issue, so apologies upfront. But - as it is unresolved with bun - perhaps it can generate some ideas for deeper diagnosis.

Essentially, the script below works as expected when run under pure Node Js, but fails when run with BunJs.

Repro script

import { Client, fql, FaunaError } from 'fauna'

const db = new Client({ secret: '==REDACTED==' })

const strongcloud_org_id = '==REDACTED==='

try {
    // query calls a user-defined function on fauna, like a stored proc. UDF is valid and OK.
   const query = fql`templates_by_organization(${strongcloud_org_id})`

  const result = await db.query(query)

  console.log( 'OK', result )

  db.close()

} catch (error) {
  if (error instanceof FaunaError) {
    // handle errors
    console.log('NOT-OK', error)
  }
}

Results (Node v18.17.1)

npx tsx fauna-client.ts
  data: {
    org: { name: 'Strongcloud Software' },
    templates: Page { data: [Array], after: undefined }
  },
  static_type: '{ templates: Never, org: { name: Any } | Null }',
  summary: '',
  txn_ts: 1698167283539860,
  stats: { 
// data truncated for space in this issue report

Results (Bun)

bun fauna-client.ts  
NOT-OK 250 | };
251 | var NetworkError = class extends FaunaError {
252 |   constructor(message, options) {
253 |     super(message, options);
254 |     if (Error.captureStackTrace) {
255 |       Error.captureStackTrace(this, NetworkError);
          ^
NetworkError: The network connection encountered a problem.
      at new NetworkError (/Users/kevinm/Projects/Strongcloud/fauna-lab/issue_6204/node_modules/fauna/dist/node/index.js:255:6)
      at /Users/kevinm/Projects/Strongcloud/fauna-lab/issue_6204/node_modules/fauna/dist/node/index.js:368:16

I understand (from a similar ticket) there isn't a lot to be gleaned from NetworkError and I further understand that this probably isn't your issue, but any reaction or hint might help me express to the bun maintainers where to look.

Thkx.

Response Object

What is the rational behind the response object having data.data? Couldn't the data just be in the upper data?

const response = await DB.query(fql`Collection.index('something')`);
console.log(response.data.data)

Bug on translating numbers to floats.

an issue with js driver, this line:

      await faunaAnalyticsClient.query(fql`${0.000008}`);

is producing this on the wire:

{"arguments":{},"query":{"fql":[{"value":{"@double":"0.000008"}}]}}

but this line (pay attention to the extra decimal place):

      await faunaAnalyticsClient.query(fql`${0.0000008}`);

is producing this on the wire:

{"arguments":{},"query":{"fql":[{"value":{"@int":"8e-7"}}]}}

here is the bug: https://github.com/fauna/fauna-js/blob/main/src/tagged-type.ts#L145

We are trusting toString to give us a decimal representation.

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.