├── .gitignore
├── LICENSE
├── README.md
├── components
├── Accordion.js
├── DefaultLayout.js
├── DocsLayout.js
├── Feature.js
├── Footer.js
├── Layout.js
├── Navbar.js
├── Sidebar.js
├── SidebarLayout.js
├── Team.js
└── TeamCard.js
├── package-lock.json
├── package.json
├── pages
├── _app.js
├── docs
│ ├── getting-started.js
│ ├── index.js
│ ├── model.js
│ └── query-builder.js
└── index.js
├── public
├── dorm.png
├── github.png
├── green.png
├── linkedin.png
├── purple.png
├── red.png
└── yellow.png
└── styles
├── Accordion.module.scss
├── Docs.module.scss
├── Footer.module.scss
├── Main.module.scss
├── Navbar.module.scss
├── SidebarLayout.module.scss
├── Team.module.scss
└── globals.scss
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | lerna-debug.log*
8 |
9 | # Diagnostic reports (https://nodejs.org/api/report.html)
10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11 |
12 | # Runtime data
13 | pids
14 | *.pid
15 | *.seed
16 | *.pid.lock
17 |
18 | # Directory for instrumented libs generated by jscoverage/JSCover
19 | lib-cov
20 |
21 | # Coverage directory used by tools like istanbul
22 | coverage
23 | *.lcov
24 |
25 | # nyc test coverage
26 | .nyc_output
27 |
28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29 | .grunt
30 |
31 | # Bower dependency directory (https://bower.io/)
32 | bower_components
33 |
34 | # node-waf configuration
35 | .lock-wscript
36 |
37 | # Compiled binary addons (https://nodejs.org/api/addons.html)
38 | build/Release
39 |
40 | # Dependency directories
41 | node_modules/
42 | jspm_packages/
43 |
44 | # TypeScript v1 declaration files
45 | typings/
46 |
47 | # TypeScript cache
48 | *.tsbuildinfo
49 |
50 | # Optional npm cache directory
51 | .npm
52 |
53 | # Optional eslint cache
54 | .eslintcache
55 |
56 | # Microbundle cache
57 | .rpt2_cache/
58 | .rts2_cache_cjs/
59 | .rts2_cache_es/
60 | .rts2_cache_umd/
61 |
62 | # Optional REPL history
63 | .node_repl_history
64 |
65 | # Output of 'npm pack'
66 | *.tgz
67 |
68 | # Yarn Integrity file
69 | .yarn-integrity
70 |
71 | # dotenv environment variables file
72 | .env
73 | .env.test
74 |
75 | # parcel-bundler cache (https://parceljs.org/)
76 | .cache
77 |
78 | # Next.js build output
79 | .next
80 |
81 | # Nuxt.js build / generate output
82 | .nuxt
83 | dist
84 |
85 | # Gatsby files
86 | .cache/
87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js
88 | # https://nextjs.org/blog/next-9-1#public-directory-support
89 | # public
90 |
91 | # vuepress build output
92 | .vuepress/dist
93 |
94 | # Serverless directories
95 | .serverless/
96 |
97 | # FuseBox cache
98 | .fusebox/
99 |
100 | # DynamoDB Local files
101 | .dynamodb/
102 |
103 | # TernJS port file
104 | .tern-port
105 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 OSLabs Beta
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # dORM-website
2 | website repo for dORM
3 |
--------------------------------------------------------------------------------
/components/Accordion.js:
--------------------------------------------------------------------------------
1 | import React, { useState, useRef } from 'react';
2 | import styles from '../styles/Accordion.module.scss';
3 |
4 | function Accordion({ title, children }) {
5 | const [setActive, setActiveState] = useState('');
6 | const [setHeight, setHeightState] = useState('0px');
7 |
8 | const content = useRef(null);
9 |
10 | function toggleAccordion() {
11 | setActiveState(setActive === '' ? 'active' : '');
12 | setHeightState(
13 | setActive === 'active' ? '0px' : `${content.current.scrollHeight}px`
14 | );
15 | }
16 |
17 | return (
18 |
19 |
20 | {title}
21 |
22 |
30 | {/*
{children}
*/}
31 | {children}
32 |
33 |
34 | );
35 | }
36 |
37 | export default Accordion;
38 |
--------------------------------------------------------------------------------
/components/DefaultLayout.js:
--------------------------------------------------------------------------------
1 | const DefaultLayout = ({ children }) => {
2 | return {children}
;
3 | };
4 |
5 | export default DefaultLayout;
6 |
--------------------------------------------------------------------------------
/components/DocsLayout.js:
--------------------------------------------------------------------------------
1 | import Sidebar from './Sidebar';
2 | import styles from '../styles/Docs.module.scss';
3 |
4 | const DocsLayout = ({ children }) => {
5 | return (
6 |
10 | );
11 | };
12 |
13 | export default DocsLayout;
14 |
--------------------------------------------------------------------------------
/components/Feature.js:
--------------------------------------------------------------------------------
1 | import styles from '../styles/Main.module.scss';
2 |
3 | const Feature = () => {
4 | return (
5 |
6 |
FEATURES
7 |
8 |
Securely run in Deno
9 | Promise based
10 | Typescript syntax
11 |
12 |
13 |
Flexible/Chainable methods
14 | Protected from SQL injection
15 |
16 |
17 | );
18 | };
19 |
20 | export default Feature;
21 |
--------------------------------------------------------------------------------
/components/Footer.js:
--------------------------------------------------------------------------------
1 | import styles from '../styles/Footer.module.scss';
2 | import Link from 'next/link';
3 |
4 | const Footer = () => {
5 | return (
6 |
7 |
8 |
23 |
43 |
49 |
50 |
SUPPORT
51 |
52 |
FAQ
53 |
54 |
55 |
56 |
57 | MIT Licensed | Copyright © 2021 dORM. All Rights Reserved.
58 |
59 |
60 | );
61 | };
62 |
63 | export default Footer;
64 |
--------------------------------------------------------------------------------
/components/Layout.js:
--------------------------------------------------------------------------------
1 | import NavBar from './Navbar';
2 | import Footer from './Footer';
3 |
4 | const Layout = ({ children }) => {
5 | return (
6 |
13 | );
14 | };
15 |
16 | export default Layout;
17 |
--------------------------------------------------------------------------------
/components/Navbar.js:
--------------------------------------------------------------------------------
1 | import styles from '../styles/Navbar.module.scss';
2 | import Link from 'next/link';
3 | import Image from 'next/image';
4 |
5 | const NavBar = () => {
6 | return (
7 | <>
8 |
9 |
10 |
11 |
20 |
26 |
27 |
dORM
28 |
29 |
30 |
31 |
32 |
33 |
34 | Home
35 |
36 |
37 |
38 |
39 |
40 | Team
41 |
42 |
43 |
44 |
45 | Documentation
46 |
47 |
48 |
49 |
58 |
59 |
60 |
74 |
75 |
76 |
94 |
95 |
96 |
97 | >
98 | );
99 | };
100 |
101 | // const Navbar = ({ items }) => {
102 | // const [focused, setFocused] = useState(0);
103 | // function clicked(e) {
104 | // setFocused(e.CurrentTarget.id);
105 | // }
106 | // return (
107 | //
108 | //
109 | // {items.map(function (m, index) {
110 | // let style = '';
111 | // if (focused == index) {
112 | // style = 'focused';
113 | // }
114 | // // Notice the use of the bind() method. It makes the
115 | // // index available to the clicked function:
116 | // return (
117 | //
118 | // {m}
119 | //
120 | // );
121 | // })}
122 | //
123 | //
124 | // );
125 | // };
126 | export default NavBar;
127 |
--------------------------------------------------------------------------------
/components/Sidebar.js:
--------------------------------------------------------------------------------
1 | import Link from 'next/link';
2 | import Accordion from './Accordion';
3 | import SidebarLayout from './SidebarLayout';
4 | import styles from '../styles/Accordion.module.scss';
5 |
6 | const Sidebar = () => {
7 | return (
8 | <>
9 |
10 |
11 |
12 |
13 | Introduction
14 |
15 |
16 | Getting Started
17 |
18 |
19 |
20 |
21 |
22 | Insert
23 |
24 |
25 | Select
26 |
27 |
28 | Update
29 |
30 |
31 | Delete
32 |
33 |
34 | Joins
35 |
36 |
37 | Parameterizing Queries
38 |
39 |
40 | toString and toObject
41 |
42 |
43 | Raw
44 |
45 |
46 |
47 |
48 | Table Models
49 |
50 |
51 |
52 |
53 | >
54 | );
55 | };
56 |
57 | export default Sidebar;
58 |
--------------------------------------------------------------------------------
/components/SidebarLayout.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import styles from '../styles/SidebarLayout.module.scss';
3 |
4 | const SidebarLayout = ({ width, height, children }) => {
5 | const [xPosition, setX] = React.useState(-width);
6 |
7 | // const toggleMenu = () => {
8 | // if (xPosition < 0) {
9 | // setX(0);
10 | // } else {
11 | // setX(-width);
12 | // }
13 | // };
14 |
15 | React.useEffect(() => {
16 | setX(0);
17 | }, []);
18 |
19 | return (
20 | <>
21 |
29 | {/*
toggleMenu()}
31 | className="toggle-menu"
32 | style={{
33 | transform: `translate(${width}px, 20vh)`
34 | }}
35 | > */}
36 |
{children}
37 |
38 | >
39 | );
40 | };
41 |
42 | export default SidebarLayout;
43 |
--------------------------------------------------------------------------------
/components/Team.js:
--------------------------------------------------------------------------------
1 | import Image from 'next/image';
2 | import styles from '../styles/Team.module.scss';
3 | import TeamCard from './TeamCard';
4 |
5 | export default function Team() {
6 | return (
7 | <>
8 |
9 |
16 |
23 |
30 |
37 |
38 | >
39 | );
40 | }
41 |
--------------------------------------------------------------------------------
/components/TeamCard.js:
--------------------------------------------------------------------------------
1 | import styles from '../styles/Team.module.scss';
2 | import Image from 'next/image';
3 |
4 | const TeamCard = ({ name, profilePic, quote, github, linkedin }) => {
5 | return (
6 |
7 |
8 |
{name}
9 |
{quote}
10 |
30 |
31 | );
32 | };
33 |
34 | export default TeamCard;
35 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "dorm-website",
3 | "version": "1.0.0",
4 | "description": "documentation website for dORM",
5 | "main": "index.js",
6 | "scripts": {
7 | "dev": "next dev",
8 | "build": "next build",
9 | "start": "next start"
10 | },
11 | "repository": {
12 | "type": "git",
13 | "url": "git+https://github.com/oslabs-beta/dORM-website.git"
14 | },
15 | "author": "Hanji Chen, Han Chae, Nick Stillman, Myo Aung",
16 | "license": "ISC",
17 | "bugs": {
18 | "url": "https://github.com/oslabs-beta/dORM-website/issues"
19 | },
20 | "homepage": "https://github.com/oslabs-beta/dORM-website#readme",
21 | "dependencies": {
22 | "next": "^10.1.3",
23 | "react-syntax-highlighter": "^15.4.3"
24 | },
25 | "devDependencies": {
26 | "react": "^17.0.2",
27 | "react-dom": "^17.0.2",
28 | "sass": "^1.32.8"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/pages/_app.js:
--------------------------------------------------------------------------------
1 | import { useRouter } from 'next/router';
2 | import Layout from '../components/Layout';
3 | import DocsLayout from '../components/DocsLayout';
4 | import DefaultLayout from '../components/DefaultLayout';
5 | import '../styles/globals.scss';
6 |
7 | function MyApp({ Component, pageProps }) {
8 | const router = useRouter();
9 |
10 | let returnComponent = (
11 |
12 |
13 |
14 | );
15 |
16 | if (router.pathname.includes('/docs')) {
17 | returnComponent = (
18 |
19 |
20 |
21 |
22 |
23 | );
24 | }
25 |
26 | return returnComponent;
27 | }
28 |
29 | // function MyApp({ Component, pageProps }) {
30 | // const InnerLayout = Component.Layout || DefaultLayout;
31 | // return (
32 | //
33 | //
34 | //
35 | //
36 | //
37 | // );
38 | // }
39 |
40 | export default MyApp;
41 |
--------------------------------------------------------------------------------
/pages/docs/getting-started.js:
--------------------------------------------------------------------------------
1 | import SyntaxHighlighter from 'react-syntax-highlighter';
2 | import { nord } from 'react-syntax-highlighter/dist/cjs/styles/hljs';
3 |
4 | const gettingStarted = () => {
5 | const codeHighlight1 = `\n$deno run --allow-read --allow-write --allow-net --unstable deno.land/x/dorm/models/init.ts\n`;
6 | const codeHighlight2 = `\nimport { Dorm } from 'https://deno.land/x/dorm/mod.ts'\n`;
7 | const codeHighlight3 = `\nimport { Dorm } from 'https://deno.land/x/dorm/mod.ts'\nimport { config } from 'https://deno.land/x/dotenv/mod.ts'
8 | \nconst env = config();
9 | \nconst URL = 'postgres://\${env.USERNAME}:\${env.PASSWORD}@\${env.SERVER}:5432/\${env.USERNAME}';
10 | \nconst dorm = new Dorm(URL)`;
11 | const codeHighlight4 = `\nimport { Dorm } from 'https://deno.land/x/dorm/mod.ts';
12 | \nconst URL = 'postgres://\${USERNAME}:\${PASSWORD}@\${SERVER}:5432/\${USERNAME}';
13 | \nconst dorm = new Dorm(URL);`;
14 |
15 | return (
16 |
17 |
INTRODUCTION
18 |
19 | We’ve noticed that many developers don’t want or need to spend their
20 | time crafting long, elaborate SQL queries with nary a comma out of
21 | place, let alone worry about parameterizing every value or concatenating
22 | every element from a front-end request object into a query string. SQL
23 | syntax can be intimidating, exhausting, overwhelming, awkward, clunky,
24 | and just plain no fun to write and reason about. It’s powerful, but
25 | requires extra cognitive load to transition from thinking in
26 | Javascript/Typescript syntax to thinking in SQL-style syntax…
27 |
28 |
Enter dORM
29 |
30 | dORM is an uber-lightweight SQL query builder for postgresQL and is
31 | currently being expanded into a full-fledged object-relational mapping
32 | (ORM) tool. Its purpose is to make your life easier when making SQL
33 | queries and let you write queries in familiar Javascript/Typescript
34 | syntax and dot notation. dORM runs in Deno, a secure runtime environment
35 | which supports Typescript out of the box and offers cloud-based package
36 | management among other great features.
37 |
38 |
39 | You can chain our methods together, use .then() at the end of the query
40 | methods or simply await the results; you can even take advantage of
41 | Deno’s top-level await. dORM is promise-based and makes async database
42 | queries a breeze. It also handles creating the connection to the
43 | database server, using deno-postgres under the hood.
44 |
45 |
46 | This guide will cover the basics of getting started with dORM. Later on
47 | we will explore some of dORM’S newest features related to
48 | object-relational mapping, but first let’s dive into some essential CRUD
49 | functionality with dORM’s query builder.{' '}
50 |
51 |
52 |
GETTING STARTED
53 |
54 | dORM can create an .env file for you to securely hold your postgres
55 | connection string. From anywhere in your project folder, you can execute
56 | this in your terminal:
57 |
58 |
63 | {codeHighlight1}
64 |
65 |
The .env file is created in your project’s root directory.
66 |
In your project, import the dORM query builder with:
67 |
72 | {codeHighlight2}
73 |
74 |
If using a .env file, you can use config like so:
75 |
80 | {codeHighlight3}
81 |
82 |
83 | If you don’t use .env (we recommend using it!), you can of course pass
84 | your database connection string directly to Dorm too:{' '}
85 |
86 |
91 | {codeHighlight4}
92 |
93 |
94 |
And that’s it—you’re ready to start making queries!
95 |
96 | );
97 | };
98 |
99 | export default gettingStarted;
100 |
--------------------------------------------------------------------------------
/pages/docs/index.js:
--------------------------------------------------------------------------------
1 | import styles from '../../styles/Docs.module.scss';
2 |
3 | function Docs() {
4 | return (
5 |
6 |
🚧 UNDER CONSTRUCTION 🚧
7 | 🚧 UNDER CONSTRUCTION 🚧
8 | 🚧 UNDER CONSTRUCTION 🚧
9 | 🚧 UNDER CONSTRUCTION 🚧
10 | 🚧 UNDER CONSTRUCTION 🚧
11 | 🚧 UNDER CONSTRUCTION 🚧
12 | 🚧 UNDER CONSTRUCTION 🚧
13 | 🚧 UNDER CONSTRUCTION 🚧
14 | 🚧 UNDER CONSTRUCTION 🚧
15 | 🚧 UNDER CONSTRUCTION 🚧
16 | 🚧 UNDER CONSTRUCTION 🚧
17 | 🚧 UNDER CONSTRUCTION 🚧
18 | 🚧 UNDER CONSTRUCTION 🚧
19 | 🚧 UNDER CONSTRUCTION 🚧
20 | 🚧 UNDER CONSTRUCTION 🚧
21 | 🚧 UNDER CONSTRUCTION 🚧
22 | 🚧 UNDER CONSTRUCTION 🚧
23 | 🚧 UNDER CONSTRUCTION 🚧
24 |
25 | );
26 | }
27 |
28 | export default Docs;
29 |
--------------------------------------------------------------------------------
/pages/docs/model.js:
--------------------------------------------------------------------------------
1 | import SyntaxHighlighter from 'react-syntax-highlighter';
2 | import { nord } from 'react-syntax-highlighter/dist/cjs/styles/hljs';
3 |
4 | const model = () => {
5 | const codeHighlight1 = `\n$deno run --allow-read --allow-write --allow-net --unstable deno.land/x/dorm/models/init.ts\n`;
6 | const codeHighlight2 = `\ndorm_databaseURL =
7 | 'postgresql://USERNAME:PASSWORD@localhost:5432/DATABASENAME?schema=public\n`;
8 | const codeHighlight3 = `\n$deno run --allow-read --allow-write --allow-net --unstable deno.land/x/dorm/models/model-generator.ts\n`;
9 | return (
10 |
11 |
MODEL INSTANCES
12 |
13 | dORM can create model instances from your database. Run
14 | this in your command line terminal:
15 |
16 |
17 |
22 | {codeHighlight1}
23 |
24 |
25 |
26 | This will create a .env file for you in your app root directory
27 | and create place holder for database url. If the .env file is
28 | already created, it will be appendeded.
29 |
30 |
31 |
36 | {codeHighlight2}
37 |
38 |
39 |
40 | Replace USERNAME , PASSWORD and DATABASENAME {' '}
41 | with your database information.
42 |
43 |
44 | After the .env file was created, execute the following command
45 | to get all the relations from your database
46 |
47 | (you will also see this instruction in.env file)
48 |
49 | :
50 |
51 |
52 |
57 | {codeHighlight3}
58 |
59 |
60 |
61 | This will create a dorm folder containing all of your table relations as
62 | model instance files.
63 |
64 |
65 | );
66 | };
67 |
68 | export default model;
69 |
--------------------------------------------------------------------------------
/pages/docs/query-builder.js:
--------------------------------------------------------------------------------
1 | import SyntaxHighlighter from 'react-syntax-highlighter';
2 | import { nord } from 'react-syntax-highlighter/dist/cjs/styles/hljs';
3 |
4 | const queryBuilder = () => {
5 | const codeHighlight1 = `\nconst inserted = await dorm
6 | .insert([
7 | { name: 'Hello World', email: 'user@dorm.com' },
8 | { name: 'Elvis', _id: 1, age: 50 },
9 | ])
10 | .table('user')
11 | .returning()
12 | .then((data: any) => data.rows)
13 | .catch((e: any) => e);\n`;
14 | const codeHighlight2 = `\ntry {
15 | const inserted = await dorm
16 | .insert([
17 | {
18 | 'name':'Hello World',
19 | 'email': 'user@dorm.com'
20 | },
21 | {
22 | name: 'Elvis',
23 | '_id': 1, age: 50
24 | }
25 | ])
26 | .table('user')
27 | .returning()
28 | }
29 | catch(e:any) {
30 | console.log(e);
31 | }\n`;
32 | const codeHighlight3 = `\nawait dorm
33 | .select('name')
34 | .from('people')
35 | .where('_id=1')
36 | .then((data: any) => {
37 | return data.rows;
38 | })
39 | .catch((e: any) => {
40 | throw e;
41 | });\n`;
42 | const codeHighlight4 = `\n.where("name = 'Jack \'\'Killer\'\' Chen' ");\n`;
43 | const codeHighlight5 = `\nawait dorm
44 | .update({ username: 'Dogs', email: 'iamnotagooddog@dogs.com' })
45 | .table('dropthis')
46 | .where('_id = 10')
47 | .returning()
48 | .then((data: any) => {
49 | return data.rows;
50 | })
51 | .catch((e: any) => e);\n`;
52 | const codeHighlight6 = `\nawait dorm
53 | .update({ username: 'Dogs', email: 'iamnotagooddog@dogs.com' })
54 | .table('dropthis')
55 | .where('_id = 10')
56 | .returning()
57 | .then((data: any) => {
58 | return data.rows;
59 | })
60 | .catch((e: any) => e);\n`;
61 | const codeHighlight7 = `\nawait dorm
62 | .delete()
63 | .from('dropthis')
64 | .where('"_id" = \${updateId}')
65 | .returning()
66 | .then((data: any) => {
67 | return data;
68 | })
69 | .catch((e: any) => e);\n`;
70 | const codeHighlight8 = `\n .innerJoin() OR .join();
71 | .leftOuterJoin() OR leftJoin();
72 | .rightOuterJoin() OR .rightJoin();
73 | .fullOuterJoin() OR .fullJoin();\n`;
74 | const codeHighlight9 = `\n await dorm
75 | .select()
76 | .from('people')
77 | .join('people_in_films')
78 | .on('people._id = people_in_films.person_id')
79 | .leftJoin('films')
80 | .on('people_in_films.film_id = films._id');;\n`;
81 | const codeHighlight10 = `\n const test = dorm
82 | .insert({'username':'Golden_Retreiver','password': 'golDenR','email':'iamagooddog@dogs.com'})
83 | .table('userprofile')
84 | .toObj()
85 |
86 | //expected output-->
87 | {
88 | text: "INSERT INTO userprofile (username, password, email) VALUES ($1, $2, $3)",
89 | values: [
90 | "Golden_Retreiver","golDenR","iamagooddog@dogs.com"
91 | ]
92 | }\n`;
93 | const codeHighlight11 = `\n const values = [1, ‘Bob’];
94 | const results = await dorm.raw(‘SELECT * FROM people WHERE id = $1 OR name = $2’, values)\n`;
95 | const codeHighlight12 = `\n const querystring = await dorm.select().from('people').where('id = 1');
96 |
97 | Returned: {
98 | text: 'SELECT * FROM people WHERE id = $1',
99 | values: [1]
100 | };\n`;
101 | const codeHighlight13 = `\n const values = [1, 'Bob'];
102 | const results = await dorm.raw(
103 | 'SELECT * FROM people WHERE id = $1 OR name = $2',
104 | values
105 | );\n`;
106 |
107 | return (
108 |
109 |
INSERT
110 |
111 | dORM simplifies the process of inserting multiple
112 | values into multiple columns of a table. If you only have a single
113 | object, you can pass that in without putting it inside an array.
114 | `.returning()` with no arguments will function as returning all. To use
115 | top level await use try catch block:
116 |
117 |
118 |
123 | {codeHighlight1}
124 |
125 |
126 |
127 | dORM simplifies the process of inserting multiple
128 | values into multiple columns of a table. If you only have a single
129 | object, you can pass that in without putting it inside an array. To use
130 | top level await use try catch block:
131 |
132 |
133 |
138 | {codeHighlight2}
139 |
140 |
141 |
SELECT
142 |
143 | .where() takes as an argument a string that defines a
144 | condition. Conditions can contain logical operators such as `AND/OR`.
145 | Currently, a value in a .where() string can be a string(wrapped
146 | in single quotes), a number, null, or boolean. Double-quotes cannot be
147 | used inside a single-quoted string value, and neither single nor double
148 | quotes can be used anywhere else inside the condition string. Unicode
149 | tokens (\uxxxx.) currently cannot be used anywhere in the condition
150 | string.
151 |
152 |
153 |
158 | {codeHighlight3}
159 |
160 |
161 |
162 | If you want to use single quotes inside your single-quoted string value,
163 | use two single-quotes in a row (using backslashes to escape) and be sure
164 | to use double-quotes around your `.where()` argument.
165 |
166 |
167 |
172 | {codeHighlight4}
173 |
174 |
175 |
UPDATE
176 |
177 |
182 | {codeHighlight5}
183 |
184 |
185 |
186 | The .update() method takes a single object, with the key/value
187 | pairs corresponding to the column names and values to update in the
188 | database.
189 |
190 |
191 |
196 | {codeHighlight6}
197 |
198 |
199 |
200 | Our .update() method won’t work without a .where() {' '}
201 | attached. If you for some extravagant reason wanted to update your whole
202 | table in such a way, that’s fine: for your convenience and well-being,
203 | we’ve provided an .updateAll() method that requires (and
204 | accepts) no .where() . Here is an example of updating all rows
205 | using dORM :
206 |
207 |
DELETE
208 |
209 | Similar to .update() and .updateAll() ,{' '}
210 | dORM has .delete() and
211 | .deleteAll() . The .delete() method requires a{' '}
212 | .where() clause,
213 | .deleteAll() does not. And as an extra safeguard, if you do
214 | include a.where() with .deleteAll() ,{' '}
215 | dORM will throw an error because it can read your mind
216 | and it knows you didn’t intend to do that.
217 |
218 |
219 |
224 | {codeHighlight7}
225 |
226 |
227 |
DROP
228 |
229 | .drop() for deleting tables. Pass the table as an argument to{' '}
230 | .drop() , or use the .table() method or one of its
231 | aliases: .from() or .into() . Please proceed with
232 | caution.
233 |
234 |
235 |
240 | {codeHighlight8}
241 |
242 |
243 |
JOIN
244 |
245 | dORM puts several join methods at your fingertips, each
246 | with an alias.
247 |
248 |
249 |
254 | {codeHighlight9}
255 |
256 |
257 |
258 | .on() takes a string argument that defines a condition for the{' '}
259 | .join() . Although it’s probably most common to put the{' '}
260 | .on() directly after the .join() it refers to,{' '}
261 | dORM allows you considerable leeway here. As long as
262 | the number of .on() methods equals the number of{' '}
263 | .join() methods, dORM is happy. It will pair
264 | them up in the order they appear, ie. the first on with the first join,
265 | second on with second join, etc.
266 |
267 |
PARAMETERIZED QUERIES
268 |
269 | PostgresQL advised that all values in a query should be parameterized.
270 | Here’s how that works with dORM . With the{' '}
271 | .insert() or .update() methods, the values you include
272 | will be automatically parameterized. The passed-in object and the final
273 | query string sent to the database will look something like this:
274 |
275 |
276 |
281 | {codeHighlight10}
282 |
283 |
284 |
285 | For .where() and .on() arguments,{' '}
286 | dORM will parse the argument and parameterize any
287 | _string, number, boolean,_ or _null values._ When dORM {' '}
288 | queries the database, it sends the parameterized query string as the
289 | first argument, and an array of values (if any) as the second
290 | argument. Postgres handles everything from there, scrubbing the values
291 | to ensure no SQL injection can occur.
292 |
293 |
294 |
299 | {codeHighlight11}
300 |
301 |
302 |
TOSTRING / TOOBJECT
303 |
304 | Perhaps there will be times when you want to create a query, but don’t
305 | want to send it off to the database just yet. dORM has
306 | a couple of methods to help you with that. A dORM query
307 | string is sent off to the database upon reaching a .then in the chain,
308 | or an await. You can intercept the query string with the{' '}
309 | .toString()
310 | method, which returns just the string with the values parameterized{' '}
311 | (ie. '...WHERE id = $1') . If you already have the values handy,
312 | that’s great, but if you’d want the values array returns as well, the
313 | .toObject() (alias .toObj) method will return an object with
314 | two properties: text and values.
315 |
316 |
317 |
322 | {codeHighlight12}
323 |
324 |
325 |
RAW
326 |
327 | Sometimes you just can’t or don’t want to use our chainable methods to
328 | access your database. We get it. For those funky queries that our
329 | methods don’t quite (yet) cover, we give you the{' '}
330 | dorm.raw()
331 | method. Pass in your query string and we will make the connection for
332 | you and send it off to the db server as-is. If you’ve parameterized your
333 | values—and of course you have!—you can pass your ordered values array as
334 | a second argument to .raw() and we’ll send that along too. This
335 | method also has aliases: .rawr() and .rawrr() , of
336 | course.
337 |
338 |
339 |
344 | {codeHighlight13}
345 |
346 |
347 |
348 |
349 | );
350 | };
351 |
352 | export default queryBuilder;
353 |
--------------------------------------------------------------------------------
/pages/index.js:
--------------------------------------------------------------------------------
1 | import Head from 'next/head';
2 | import Link from 'next/link';
3 | import Image from 'next/image';
4 | import Team from '../components/Team';
5 | import Feature from '../components/Feature';
6 | import styles from '../styles/Main.module.scss';
7 |
8 | export default function Home() {
9 | return (
10 | <>
11 |
12 |
19 |
20 |
21 |
dORM
22 |
23 | dORM is an uber-lightweight postgreSQL query builder for Deno and is
24 | currently being expanded into a full-fledged object-relational mapping
25 | (ORM) tool. Its purpose is to make your life easier when making SQL
26 | queries and let you write queries in familiar Javascript/Typescript
27 | syntax and dot notation.
28 |
29 |
30 |
Get Started
31 |
32 |
33 |
40 |
41 |
42 |
43 |
44 | TEAM
45 |
46 |
47 |
48 | >
49 | );
50 | }
51 |
--------------------------------------------------------------------------------
/public/dorm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oslabs-beta/dORM-website/9ae454a70a2e576f7ea4109b44bd5de9ce3de924/public/dorm.png
--------------------------------------------------------------------------------
/public/github.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oslabs-beta/dORM-website/9ae454a70a2e576f7ea4109b44bd5de9ce3de924/public/github.png
--------------------------------------------------------------------------------
/public/green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oslabs-beta/dORM-website/9ae454a70a2e576f7ea4109b44bd5de9ce3de924/public/green.png
--------------------------------------------------------------------------------
/public/linkedin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oslabs-beta/dORM-website/9ae454a70a2e576f7ea4109b44bd5de9ce3de924/public/linkedin.png
--------------------------------------------------------------------------------
/public/purple.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oslabs-beta/dORM-website/9ae454a70a2e576f7ea4109b44bd5de9ce3de924/public/purple.png
--------------------------------------------------------------------------------
/public/red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oslabs-beta/dORM-website/9ae454a70a2e576f7ea4109b44bd5de9ce3de924/public/red.png
--------------------------------------------------------------------------------
/public/yellow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oslabs-beta/dORM-website/9ae454a70a2e576f7ea4109b44bd5de9ce3de924/public/yellow.png
--------------------------------------------------------------------------------
/styles/Accordion.module.scss:
--------------------------------------------------------------------------------
1 | @import url('https://fonts.googleapis.com/css?family=Open+Sans:400,600&display=swap');
2 |
3 | /* Style the accordion section */
4 | .accordionSection {
5 | color: #343434;
6 | display: flex;
7 | flex-direction: column;
8 | }
9 |
10 | /* Style the buttons that are used to open and close the accordion panel */
11 | .accordion {
12 | background-color: rgb(255, 255, 255);
13 | color: #343434;
14 | cursor: pointer;
15 | height: 50px;
16 | // padding: 10px;
17 | margin: 10px;
18 | display: flex;
19 | align-items: center;
20 | border: none;
21 | border-radius: 10px;
22 | outline: none;
23 | // transition: color 0.3s ease-in-out;
24 | transition: background-color 0.3s ease;
25 |
26 | // border: 1px red solid;
27 | }
28 |
29 | /* Add a background color to the button if it is clicked on (add the .active class with JS), and when you move the mouse over it (hover) */
30 | .accordion:hover {
31 | color: white;
32 | background-color: #a083c4;
33 | }
34 | /* Style the accordion content title */
35 | .accordionTitle {
36 | font-weight: 500;
37 | font-size: 1.5rem;
38 | text-align: left;
39 | }
40 |
41 | /* Style the accordion content panel. Note: hidden by default */
42 | .accordionContent {
43 | background-color: rgb(255, 255, 255);
44 | cursor: pointer;
45 | overflow: hidden;
46 | transition: background-color 0.3s ease-in-out;
47 | transition: color 0.3s ease-in-out;
48 | }
49 |
50 | /* Style the accordion content text */
51 | .accordionText {
52 | font-weight: 500;
53 | font-size: 20px;
54 | padding: 18px 0 18px 30px;
55 | }
56 |
57 | .accordionText:hover {
58 | color: #ffc55e;
59 | // background-color: #a083c4;
60 | }
61 |
--------------------------------------------------------------------------------
/styles/Docs.module.scss:
--------------------------------------------------------------------------------
1 | .container {
2 | display: flex;
3 | flex-direction: row;
4 | flex-wrap: nowrap;
5 | }
6 |
7 | .docContents {
8 | padding: 0 10rem;
9 | width: 100%;
10 | height: 100vh;
11 | overflow-y: scroll;
12 | // -webkit-overflow-scrolling: auto;
13 |
14 | h1 {
15 | color: #7851a9;
16 | font-size: 3.5rem;
17 | text-align: left;
18 | margin-bottom: 0;
19 | margin-top: 7rem;
20 | }
21 |
22 | h2 {
23 | color: #4f4f4f;
24 | margin-top: 0;
25 | font-size: 2rem;
26 | }
27 |
28 | p {
29 | color: #4f4f4f;
30 | margin: 0;
31 | padding-bottom: 2rem;
32 | font-size: 1.7rem;
33 | line-height: 3rem;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/styles/Footer.module.scss:
--------------------------------------------------------------------------------
1 | .container {
2 | display: flex;
3 | flex-direction: column;
4 | background-color: rgb(240, 240, 240);
5 | padding: 3rem 8rem;
6 | height: 250px;
7 |
8 | .footerContainer {
9 | display: flex;
10 | flex-direction: row;
11 | justify-content: center;
12 |
13 | // border: 1px solid red;
14 | h4 {
15 | color: #343434;
16 | font-size: 20px;
17 | margin: 0 0 2rem;
18 | }
19 |
20 | .directoryContainer {
21 | display: flex;
22 | flex-direction: column;
23 | align-items: left;
24 | padding: 0 7.5rem;
25 |
26 | a {
27 | // margin: 0.2rem 0;
28 | color: #343434;
29 | text-decoration: none;
30 | font-size: 20px;
31 | }
32 | a:hover {
33 | color: #ffc55e;
34 | }
35 | }
36 | }
37 |
38 | .copyright {
39 | display: flex;
40 | flex-direction: column;
41 | align-items: center;
42 |
43 | padding-top: 5rem;
44 | font-size: 0.8rem;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/styles/Main.module.scss:
--------------------------------------------------------------------------------
1 | .landingPageIntro {
2 | width: auto;
3 | min-height: 800px;
4 | height: 100vh;
5 |
6 | background: #7851a9; /* fallback for old browsers */
7 | background: -webkit-linear-gradient(
8 | to left,
9 | #fff,
10 | #7851a9
11 | ); /* Chrome 10-25, Safari 5.1-6 */
12 | background: linear-gradient(
13 | to top,
14 | #fff,
15 | #7851a9
16 | ); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
17 | position: relative;
18 | display: flex;
19 | flex-direction: column;
20 | align-items: center;
21 | justify-content: center;
22 |
23 | h1 {
24 | color: white;
25 | font-size: 150px;
26 | text-shadow: 2px 2px 2px white;
27 | margin: 0;
28 | }
29 |
30 | p {
31 | margin-bottom: 2rem;
32 | line-height: 2.2rem;
33 | width: 1000px;
34 | color: #565656;
35 | font-size: 25px;
36 | font-weight: 600;
37 | text-align: center;
38 | }
39 |
40 | button {
41 | color: white;
42 | background-color: transparent;
43 |
44 | width: 300px;
45 | height: 100px;
46 | border: solid 5px white;
47 | border-radius: 20px;
48 | box-shadow: none;
49 | cursor: pointer;
50 |
51 | font-size: 32px;
52 | font-weight: 900;
53 |
54 | transition: border 0.5s ease-in-out;
55 |
56 | &:hover {
57 | color: white;
58 | background-color: #ffc55e;
59 |
60 | border: transparent;
61 | transition: color 0.5s ease-in-out;
62 | transition: background-color 0.5s ease-in-out;
63 | }
64 |
65 | &:focus {
66 | outline: 0;
67 | }
68 | }
69 | }
70 |
71 | .featureContainer {
72 | min-height: 800px;
73 | height: 100vh;
74 |
75 | display: flex;
76 | text-align: center;
77 | flex-direction: column;
78 | align-items: center;
79 | justify-content: center;
80 | color: #343434;
81 |
82 | h1 {
83 | font-size: 90px;
84 | }
85 |
86 | h2 {
87 | font-size: 30px;
88 | }
89 |
90 | .featureSubContainer {
91 | display: flex;
92 | width: 250%;
93 | flex-direction: row;
94 | justify-content: space-around;
95 | margin-bottom: 5rem;
96 |
97 | color: #343434;
98 | }
99 | .featureSubContainer2 {
100 | display: flex;
101 | width: 150%;
102 | flex-direction: row;
103 | justify-content: space-around;
104 | margin-bottom: 10rem;
105 |
106 | color: #343434;
107 | }
108 | }
109 |
110 | .teamContainer {
111 | display: flex;
112 | flex-direction: column;
113 | align-items: center;
114 | justify-content: center;
115 | padding-bottom: 10rem;
116 | min-height: 800px;
117 | height: 100vh;
118 | color: #343434;
119 |
120 | .teamContainerTitle {
121 | font-size: 90px;
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/styles/Navbar.module.scss:
--------------------------------------------------------------------------------
1 | .nav {
2 | display: flex;
3 | flex-direction: row;
4 | justify-content: space-between;
5 | align-items: center;
6 | padding: 1rem;
7 | height: 5rem;
8 | border-bottom: 1px black solid;
9 |
10 | // position: fixed;
11 | // width: 100%;
12 | h1 {
13 | margin: 0;
14 | font-size: 70px;
15 | -webkit-text-stroke: 2px #663399;
16 | color: white;
17 | text-shadow: 2px 2px 2px #663399;
18 |
19 | &:hover {
20 | color: #663399;
21 | cursor: pointer;
22 | transition: color 0.2s ease-in-out;
23 | }
24 | }
25 | }
26 |
27 | .navMainLogo {
28 | display: flex;
29 | flex-direction: row-reverse;
30 | align-items: center;
31 | }
32 |
33 | .navContainer {
34 | color: #565656;
35 | display: flex;
36 | flex-direction: row;
37 | justify-content: flex-end;
38 | align-items: center;
39 |
40 | li {
41 | list-style-type: none;
42 | // padding: 10px;
43 | // display: inline-block;
44 | // padding: 10px 20px;
45 | // cursor: pointer;
46 | // background-color: #eee;
47 | // color: #7b8585;
48 |
49 | // transition: 0.3s;
50 | }
51 |
52 | div {
53 | font-size: 1.5rem;
54 | font-weight: 500;
55 | padding: 10px;
56 | &:hover {
57 | text-decoration: underline 5px #ffc55e;
58 | cursor: pointer;
59 | }
60 | }
61 |
62 | a {
63 | color: #565656;
64 | // text-decoration: none;
65 | text-decoration: underline 5px transparent;
66 | &:hover {
67 | text-decoration: underline 5px #ffc55e;
68 | cursor: pointer;
69 | }
70 | }
71 | }
72 |
73 | // .navIcon {
74 | // padding: 10px;
75 | // &:hover {
76 | // text-decoration: underline 2px #7851a9;
77 | // cursor: pointer;
78 | // }
79 | // }
80 |
81 | // .li:hover {
82 | // background-color: #beecea;
83 | // }
84 | // .li.focused {
85 | // color: #fff;
86 | // background-color: #41c7c2;
87 | // }
88 |
--------------------------------------------------------------------------------
/styles/SidebarLayout.module.scss:
--------------------------------------------------------------------------------
1 | .sideBar {
2 | height: 100% !important;
3 | display: flex;
4 | flex-direction: column;
5 | border-right: 1px solid;
6 |
7 | overflow-y: auto;
8 |
9 | border-color: rgba(0, 0, 0, 0.693);
10 | background-color: rgb(255, 255, 255);
11 |
12 | transition: 0.8s ease;
13 | }
14 |
--------------------------------------------------------------------------------
/styles/Team.module.scss:
--------------------------------------------------------------------------------
1 | .teamComp {
2 | display: flex;
3 | flex-direction: row;
4 | justify-content: center;
5 | align-items: center;
6 | }
7 |
8 | .teamCard {
9 | color: #5d5d5d;
10 | padding: 2rem 3rem 0;
11 |
12 | display: flex;
13 | flex-direction: column;
14 | justify-content: center;
15 |
16 | h1 {
17 | margin: 0.3rem 0;
18 | font-size: 40px;
19 | // text-shadow: 1px 1px 1px #5d5d5d;
20 | }
21 | h4 {
22 | font-size: 22.5px;
23 | margin: 0.3rem 0 0.5rem;
24 | color: #868686;
25 | }
26 | }
27 |
28 | .logoRow {
29 | width: 90px;
30 | display: flex;
31 | flex-direction: row;
32 | justify-content: space-between;
33 | }
34 |
35 | .logo {
36 | padding: 5px;
37 | border-radius: 50%;
38 | cursor: pointer;
39 |
40 | &:hover {
41 | // do something
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/styles/globals.scss:
--------------------------------------------------------------------------------
1 | body {
2 | padding: 0;
3 | margin: 0;
4 | overflow: hidden;
5 | }
6 |
7 | html h1,
8 | h2,
9 | h3,
10 | h4,
11 | p,
12 | body,
13 | a {
14 | font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
15 | }
16 |
17 | html {
18 | overflow-y: scroll;
19 | }
20 |
21 | .page-container {
22 | // padding-bottom: 20rem
23 | }
24 |
25 | .contentFooterContainer {
26 | display: flex;
27 | flex-direction: column;
28 | // position: relative;
29 | // min-height: 100vh;
30 | }
31 |
32 | pre {
33 | counter-reset: line;
34 | }
35 |
36 | code {
37 | counter-increment: line;
38 | }
39 |
40 | code::before {
41 | content: counter(line);
42 | display: inline-block;
43 | width: 1.5em; /* Fixed width */
44 | border-right: 1px solid #ddd;
45 | padding: 0 0.5em;
46 | margin-right: 0.5em;
47 | color: #888;
48 | -webkit-user-select: none;
49 | }
50 |
51 | .syntaxHighlighter {
52 | margin-top: 0;
53 | font-size: 1.5rem;
54 | }
55 |
--------------------------------------------------------------------------------