mirror of
https://github.com/jbranchaud/til
synced 2026-01-18 22:48:02 +00:00
Compare commits
4 Commits
88995632c6
...
9e4d61b9e5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e4d61b9e5 | ||
|
|
84e2c9c6f4 | ||
|
|
39614e975e | ||
|
|
295fe153ad |
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
||||
|
||||
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||
|
||||
_1431 TILs and counting..._
|
||||
_1433 TILs and counting..._
|
||||
|
||||
---
|
||||
|
||||
@@ -830,6 +830,7 @@ _1431 TILs and counting..._
|
||||
- [Execute A Raw SQL Query](prisma/execute-a-raw-sql-query.md)
|
||||
- [Grab A Limited Set Of Records](prisma/grab-a-limited-set-of-records.md)
|
||||
- [Open Connections To Multiple Databases](prisma/open-connections-to-multiple-databases.md)
|
||||
- [Override Table Name For Prisma Model](prisma/override-table-name-for-prisma-model.md)
|
||||
- [Specify Alternate Location For Prisma Schema](prisma/specify-alternate-location-for-prisma-schema.md)
|
||||
|
||||
### Python
|
||||
@@ -1377,6 +1378,7 @@ _1431 TILs and counting..._
|
||||
- [Find Files With fd](unix/find-files-with-fd.md)
|
||||
- [Find Newer Files](unix/find-newer-files.md)
|
||||
- [Find Occurrences Of Multiple Values With Ripgrep](unix/find-occurrences-of-multiple-values-with-ripgrep.md)
|
||||
- [Find Top-Level Directories Matching A Pattern](unix/find-top-level-directories-matching-a-pattern.md)
|
||||
- [Fix Unlinked Node Binaries With asdf](unix/fix-unlinked-node-binaries-with-asdf.md)
|
||||
- [Forward Multiple Ports Over SSH](unix/forward-multiple-ports-over-ssh.md)
|
||||
- [Generate A SAML Key And Certificate Pair](unix/generate-a-saml-key-and-certificate-pair.md)
|
||||
|
||||
@@ -5,6 +5,8 @@ an array-like object with all of the arguments to the function. Even if not
|
||||
all of the arguments are referenced in the function signature, they can
|
||||
still be accessed via the `arguments` object.
|
||||
|
||||
> For ES6+ compatibility, the `spread` operator used via [rest parameters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters) is preferred over the `arugments` object when accessing an abritrary number of function arguments.
|
||||
|
||||
```javascript
|
||||
function argTest(one) {
|
||||
console.log(one);
|
||||
|
||||
42
prisma/override-table-name-for-prisma-model.md
Normal file
42
prisma/override-table-name-for-prisma-model.md
Normal file
@@ -0,0 +1,42 @@
|
||||
# Override Table Name For Prisma Model
|
||||
|
||||
When defining your Prisma schema, you'll add models to your
|
||||
`prisma/schema.prisma` file that look something like this:
|
||||
|
||||
```
|
||||
model Book {
|
||||
id BigInt @id @default(autoincrement()) @db.BigInt
|
||||
title String
|
||||
author String
|
||||
publication_year Int
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
}
|
||||
```
|
||||
|
||||
The prisma client (ORM-layer) that gets generated will have a `Book` type and
|
||||
you'll be able to reference the model to, for instance, create a record with
|
||||
`prisma.book.create(...)`. Both of these things are derived from the model
|
||||
name: `Book`.
|
||||
|
||||
The other thing that is derived from the model name is the name given to the
|
||||
underlying database table. So you end up with a table called `Book`. You may,
|
||||
however, prefer a table naming convention where this one would be named `books`
|
||||
(snake_case and pluralized).
|
||||
|
||||
To achieve that, you have to manually override the table name with [the `@@map`
|
||||
directive](https://www.prisma.io/docs/orm/reference/prisma-schema-reference#map-1).
|
||||
Add it toward the bottom of the model like so:
|
||||
|
||||
```
|
||||
model Book {
|
||||
id BigInt @id @default(autoincrement()) @db.BigInt
|
||||
title String
|
||||
author String
|
||||
publication_year Int
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
|
||||
@@map("books")
|
||||
}
|
||||
```
|
||||
36
unix/find-top-level-directories-matching-a-pattern.md
Normal file
36
unix/find-top-level-directories-matching-a-pattern.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# Find Top-Level Directories Matching A Pattern
|
||||
|
||||
I like using [`fd`](https://github.com/sharkdp/fd) as an alternative to `find`.
|
||||
In my experience it is more intuitive to use. For instance, I wanted to find
|
||||
all the top-level directories in my current directory that contained the word
|
||||
`next`. I was able to get the command mostly right by guessing the flags, only
|
||||
checking the man page once.
|
||||
|
||||
On my first attempt, it prompted me with a suggestion for a flag that wasn't
|
||||
quite right. I tried `--depth`, but it should have been `--maxdepth`.
|
||||
|
||||
```bash
|
||||
$ fd --depth 0 next ./
|
||||
error: Found argument '--depth' which wasn't expected, or isn't valid in this context
|
||||
Did you mean --maxdepth?
|
||||
```
|
||||
|
||||
Then I checked the man page for how to specify the file type as _directory_ --
|
||||
using `-t` or `--type` with `d`.
|
||||
|
||||
And here is the command that gets me all top-level directories matching `next`
|
||||
in my current directory:
|
||||
|
||||
```bash
|
||||
$ fd --maxdepth 1 --type d next ./
|
||||
|
||||
bookshelf-nextjs-prisma-postgres
|
||||
bookshelf-prisma-nextjs-planetscale
|
||||
my-next-app
|
||||
next-bookshelf
|
||||
next-personal-site
|
||||
next-sanity-v3-example
|
||||
try-trpc-next
|
||||
```
|
||||
|
||||
See `man fd` for more details.
|
||||
Reference in New Issue
Block a user