This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// extracting the first tuple from the list | |
Tuple bookGenreTuple = bookGenreTuples.get(0); | |
// getting the first element of the tuple | |
// and converting it into a Book object | |
Book book = bookGenreTuple.get(0, Book.class); | |
// getting the second element of the tuple | |
// and converting it into a Genre object | |
Genre genre = bookGenreTuple.get(1, Genre.class); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// initializing the CriteriaBuilder and CriteriaQuery object | |
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); | |
// if you want to perform a multiselect() you need define | |
// a CriteriaQuery with the Tuple type | |
CriteriaQuery<Tuple> criteriaQuery = criteriaBuilder.createQuery(Tuple.class); | |
Root<Book> root = criteriaQuery.from(Book.class); | |
// defining the JOIN clauses | |
Join<Book, Author> author = root.join("authors"); | |
Join<Book, Genre> genre = root.join("genres"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// initializing the CriteriaBuilder and CriteriaQuery object | |
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); | |
CriteriaQuery<Book> criteriaQuery = criteriaBuilder.createQuery(Book.class); | |
Root<Book> root = criteriaQuery.from(Book.class); | |
// defining the JOIN clauses | |
Join<Book, Author> author = root.join("authors"); | |
Join<Book, Genre> genre = root.join("genres"); | |
// specifying the WHERE conditions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
web: node server.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
const path = require("path"); | |
const app = express() | |
const PORT = process.env.PORT || 3000 | |
app.use(express.static(path.join(__dirname, "build"))) | |
app.get("*", function (req, res) { | |
res.sendFile(path.join(__dirname, "build", "index.html")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
res | |
.set({ | |
"Content-Type": "text/csv", | |
"Content-Disposition": `attachment; filename="<YOUR_FILE_NAME>.csv"`, | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express") | |
const app = express() | |
app.get("/users/getCSV", function (req, res) { | |
// retrieving the user with a query... | |
const users = [ | |
{ name: "Patricia", surname: "Smith", age: null }, | |
{ name: "John", surname: null, age: 56 }, | |
{ name: "Maria", surname: "Brown", age: 37 }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# removing the .env.local file because | |
# next uses it if it is present | |
rm -f ./.env.local | |
# if this is the staging deployment environment | |
if test "$ENV" = "staging" | |
then | |
# removing the .env.production file | |
# because otherwise next would use it | |
# as the default .env file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# removing the .env.local file because | |
# react-scripts uses it if it is present | |
rm -f ./.env.local | |
# if this is the staging deployment environment | |
if test "$ENV" = "staging" | |
then | |
# removing the .env.production file | |
# because otherwise react-scripts would use it | |
# as the default .env file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const array1 = []; | |
// adding 100k elements to array1 | |
for (let i = 0; i < 500000; i++) { | |
array1.push(i); | |
} | |
// creating a copy of the array1 variable | |
const array2 = []; | |
// adding one element at a time |
NewerOlder