chore(survey): rename ownerId param to userId to match other tables

This commit is contained in:
Aminejv 2021-08-02 17:57:12 +01:00
parent 150ea7710f
commit 4050d2a2c3
6 changed files with 8 additions and 8 deletions

View File

@ -1,11 +1,11 @@
import { runQuery } from "~/node_common/data/utilities";
export default async ({ ownerId, prevTools, usecases, referrals }) => {
export default async ({ userId, prevTools, usecases, referrals }) => {
return await runQuery({
label: "CREATE_SURVEY",
queryFn: async (DB) => {
let query = await DB.insert({
ownerId,
userId,
prevTools,
usecases,
referrals,

View File

@ -37,7 +37,7 @@ export default async ({ id }) => {
const usage = await DB.from("usage").where({ userId: id }).del();
const surveys = await DB.from("surveys").where({ ownerId: id }).del();
const surveys = await DB.from("surveys").where({ userId: id }).del();
const data = await DB.from("users").where({ id }).del().returning("*");

View File

@ -1,10 +1,10 @@
import { runQuery } from "~/node_common/data/utilities";
export default async ({ ownerId }) => {
export default async ({ userId }) => {
return await runQuery({
label: "GET_SURVEY_BY_USER_ID",
queryFn: async (DB) => {
let query = await DB.select("*").from("surveys").where({ ownerId });
let query = await DB.select("*").from("surveys").where({ userId });
if (!query || query.error) {
return null;

View File

@ -159,7 +159,7 @@ export const getById = async ({ id }) => {
Data.getSubscriptionsByUserId({ ownerId: id }),
Data.getFollowingByUserId({ ownerId: id }),
Data.getFollowersByUserId({ userId: id }),
Data.getSurveyByUserId({ ownerId: id }),
Data.getSurveyByUserId({ userId: id }),
])
).map((item) => item.value);

View File

@ -21,7 +21,7 @@ export default async (req, res) => {
const { id } = userInfo;
const survey = Data.createSurvey({
ownerId: id,
userId: id,
prevTools: tools,
usecases: useCases,
referrals,

View File

@ -183,7 +183,7 @@ const createTwitterTokensTable = db.schema.createTable("twitterTokens", function
const createSurveysTable = db.schema.createTable("surveys", function (table) {
table.uuid("id").primary().unique().notNullable().defaultTo(db.raw("uuid_generate_v4()"));
table.uuid("ownerId").references("id").inTable("users");
table.uuid("userId").references("id").inTable("users");
table.string("prevTools").notNullable();
table.string("usecases").notNullable();
table.string("referrals").notNullable();