question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to bulk insert from JS client?

See original GitHub issue

Today the SurrealQL query language supports multiple-insert in a single statement as follows:

INSERT INTO company (name, founded) VALUES ('Acme Inc.', '1967-05-03'), ('Apple Inc.', '1976-04-01');

However, the JS client currently only provides db.create(), which supports a single record at at a time.

What is the best way to bulk insert when using the JS (Deno / Node / Bun) client? Should one use the raw db.query() command? If so, what is the expected syntax?

Issue Analytics

  • State:open
  • Created 10 months ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
fritzbluecommented, Dec 1, 2022

SQL injections don’t exist with surrealdb

This type of thinking is a very slippery slope. Security should never be assumed (especially with one of the top 10 web application security risks). I advocate for adding an explicit bulk insert option to the JS client so that string interpolation is not required.

1reaction
evbocommented, Dec 2, 2022

@fritzblue +1 but actually bulk loading feature for ALL client APIs is currently missing. Would be great to have a load CSV/JSON/TEXT/BINARY option like all other RDBMS and many graph dbs too (Neo4j, Janus, etc.).

Would you consider broadening the title of this issue to just be “How to bulk insert from client”?

EDIT: Whoops just noticed this is the js repo… sorry and thanks @mathe42 for pointing that out

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I do a bulk insert in mySQL using node.js
Bulk inserts are possible by using nested array, see the github page. Nested arrays are turned into grouped lists (for bulk inserts), e.g....
Read more >
How to Work With Bulk Insert Operation - RavenDB
The bulk insert operation is broken into batches, each batch is treated in its own transaction so the whole operation isn't treated under...
Read more >
Optimizing Conditional Bulk Insert in Node.js + PostgreSQL
In this article, I'm going to compare three approaches of conditional bulk insert for Node.JS and PostgreSQL:.
Read more >
Insert Multiple Documents — Node.js - MongoDB
You can insert multiple documents using the collection.insertMany() method. The insertMany() takes an array of documents to insert into the specified ...
Read more >
Safely Inserting Bulk Data to Mysql with NodeJs - Medium
1. Bulk insert ... To make this single query all we need is an array of arrays that will have your entries. ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found