Remove DB examples folder

This commit is contained in:
Convly 2022-03-17 11:42:33 +01:00
parent 447bbfed16
commit a296a55334
6 changed files with 0 additions and 497 deletions

View File

@ -1 +0,0 @@
data

View File

@ -1,36 +0,0 @@
'use strict';
const postgres = {
client: 'postgres',
connection: {
database: 'strapi',
user: 'strapi',
password: 'strapi',
},
// debug: true,
};
const mysql = {
client: 'mysql',
connection: {
database: 'strapi',
user: 'strapi',
password: 'strapi',
},
// debug: true,
};
const sqlite = {
client: 'sqlite',
connection: {
filename: 'data.sqlite',
},
useNullAsDefault: true,
// debug: true,
};
module.exports = {
sqlite,
postgres,
mysql,
};

View File

@ -1,29 +0,0 @@
version: '3'
services:
postgres:
image: postgres
restart: always
volumes:
- ./data/postgresql:/var/lib/postgresql/data
environment:
POSTGRES_USER: strapi
POSTGRES_PASSWORD: strapi
POSTGRES_DB: strapi
ports:
- '5432:5432'
mysql:
image: mysql
restart: always
command: --default-authentication-plugin=mysql_native_password
environment:
MYSQL_DATABASE: strapi
MYSQL_USER: strapi
MYSQL_PASSWORD: strapi
MYSQL_ROOT_HOST: '%'
MYSQL_ROOT_PASSWORD: strapi
volumes:
- ./data/mysql:/var/lib/mysql
ports:
- '3306:3306'

View File

@ -1,73 +0,0 @@
'use strict';
const util = require('util');
const { Database } = require('../lib/index');
const models = require('./models');
const connections = require('./connections');
async function main(connection) {
const orm = await Database.init({
connection,
models: Database.transformContentTypes(models),
});
try {
// await orm.schema.drop();
// await orm.schema.create();
await orm.schema.reset();
let res;
const c1 = await orm.query('comment').create({
data: {
title: 'coucou',
},
});
const c2 = await orm.query('video-comment').create({
data: {
title: 'coucou',
},
});
res = await orm.query('article').create({
data: {
dz: [
{
__type: 'comment',
id: c1.id,
},
{
__type: 'video-comment',
id: c2.id,
},
],
},
populate: {
dz: true,
},
});
log(res);
res = await orm.query('article').findMany({
populate: {
dz: true,
},
});
log(res);
// await tests(orm);
} finally {
orm.destroy();
}
}
function log(res) {
console.log(util.inspect(res, null, null, true));
}
main(connections.sqlite);

View File

@ -1,341 +0,0 @@
'use strict';
const category = {
modelName: 'category',
uid: 'category',
collectionName: 'categories',
attributes: {
title: {
type: 'string',
},
price: {
type: 'integer',
required: true,
default: 12,
column: {
unique: true,
nonNullable: true,
unsigned: true,
defaultTo: 12,
},
},
articles: {
type: 'relation',
relation: 'oneToMany',
target: 'article',
mappedBy: 'category',
},
compo: {
type: 'component',
component: 'compo',
},
},
};
const article = {
modelName: 'article',
uid: 'article',
collectionName: 'articles',
attributes: {
title: {
type: 'string',
},
category: {
type: 'relation',
relation: 'manyToOne',
target: 'category',
inversedBy: 'articles',
// useJoinTable: false,
},
// tags: {
// type: 'relation',
// relation: 'manyToMany',
// target: 'tag',
// inversedBy: 'articles',
// },
// compo: {
// type: 'component',
// component: 'compo',
// // repeatable: true,
// },
// cover: {
// type: 'media',
// single: true,
// },
// gallery: {
// type: 'media',
// multiple: true,
// },
},
};
const tags = {
modelName: 'tag',
uid: 'tag',
collectionName: 'tags',
attributes: {
name: {
type: 'string',
},
articles: {
type: 'relation',
relation: 'manyToMany',
target: 'article',
mappedBy: 'tag',
},
},
};
const compo = {
modelName: 'compo',
uid: 'compo',
collectionName: 'compos',
attributes: {
key: {
type: 'string',
},
value: {
type: 'string',
},
},
};
const user = {
modelName: 'user',
uid: 'user',
collectionName: 'users',
attributes: {
address: {
type: 'relation',
relation: 'oneToOne',
target: 'address',
inversedBy: 'user',
// useJoinTable: false,
},
},
};
const address = {
modelName: 'address',
uid: 'address',
collectionName: 'addresses',
attributes: {
name: {
type: 'string',
},
user: {
type: 'relation',
relation: 'oneToOne',
target: 'user',
mappedBy: 'address',
},
},
};
const file = {
modelName: 'file',
uid: 'file',
collectionName: 'files',
attributes: {
name: {
type: 'string',
},
alternativeText: {
type: 'string',
},
caption: {
type: 'string',
},
width: {
type: 'integer',
},
height: {
type: 'integer',
},
formats: {
type: 'json',
},
hash: {
type: 'string',
},
ext: {
type: 'string',
},
mime: {
type: 'string',
},
size: {
type: 'decimal',
},
url: {
type: 'string',
},
previewUrl: {
type: 'string',
},
provider: {
type: 'string',
},
provider_metadata: {
type: 'json',
},
// related: {
// type: 'relation',
// relation: 'oneToMany',
// target: 'file_morph',
// mappedBy: 'file',
// },
// related: {
// type: 'relation',
// realtion: 'morphTo',
// },
},
};
const fileMorph = {
modelName: 'file-morph',
uid: 'file-morph',
collectionName: 'file_morphs',
attributes: {
// file: {
// type: 'relation',
// relation: 'manyToOne',
// target: 'file',
// inversedBy: 'related',
// useJoinTable: false,
// },
},
};
const blogPost = {
modelName: 'blogPost',
uid: 'blogPost',
collectionName: 'blog_posts',
attributes: {
passwordField: {
type: 'password',
},
emailField: {
type: 'email',
},
stringField: {
type: 'string',
},
uidField: {
type: 'uid',
},
richtextField: {
type: 'richtext',
},
textField: {
type: 'text',
},
enumerationField: {
type: 'enumeration',
enum: ['A', 'B'],
},
jsonField: {
type: 'json',
},
bigintegerField: {
type: 'biginteger',
},
integerField: {
type: 'integer',
},
floatField: {
type: 'float',
},
decimalField: {
type: 'decimal',
},
dateField: {
type: 'date',
},
timeField: {
type: 'time',
},
datetimeField: {
type: 'datetime',
},
timestampField: {
type: 'timestamp',
},
booleanField: {
type: 'boolean',
},
},
};
module.exports = [category, article, tags, compo, user, address, file, fileMorph, blogPost];
// const article = {
// modelName: 'article',
// uid: 'article',
// collectionName: 'articles',
// attributes: {
// commentable: {
// type: 'relation',
// relation: 'morphToOne',
// },
// reportables: {
// type: 'relation',
// relation: 'morphToMany',
// },
// dz: {
// type: 'dynamiczone',
// components: ['comment', 'video-comment'],
// },
// },
// };
// const comment = {
// modelName: 'comment',
// uid: 'comment',
// collectionName: 'comments',
// attributes: {
// article: {
// type: 'relation',
// relation: 'morphOne',
// target: 'article',
// morphBy: 'commentable',
// },
// title: {
// type: 'string',
// },
// },
// };
// const videoComment = {
// modelName: 'video-comment',
// uid: 'video-comment',
// collectionName: 'video_comments',
// attributes: {
// articles: {
// type: 'relation',
// relation: 'morphMany',
// target: 'article',
// morphBy: 'commentable',
// },
// title: {
// type: 'string',
// },
// },
// };
// const folder = {
// modelName: 'folder',
// uid: 'folder',
// collectionName: 'folders',
// attributes: {
// articles: {
// type: 'relation',
// relation: 'morphMany',
// target: 'article',
// morphBy: 'reportables',
// },
// },
// };
// module.exports = [article, comment, videoComment, folder];

View File

@ -1,17 +0,0 @@
type ID = number | string;
interface Category {
id: ID;
title: string;
}
interface Article {
id: ID;
title: string;
category: Category | ID;
}
interface AllTypes {
article: Article;
category: Category;
}