Skip to content

Commit

Permalink
follow TS convention
Browse files Browse the repository at this point in the history
  • Loading branch information
codingkarthik committed Sep 23, 2024
1 parent 43bb2ee commit b7ba0f7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"scripts": {
"test": "mocha",

"ndc-test": "node script/test-setup.js",
"build": "rimraf ./build && tsc",
"start": "npm run build && ts-node ./src/index.ts",
Expand Down
15 changes: 6 additions & 9 deletions src/connector/execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ function parseQueryRequest(

let requestedFields: sql.SelectColumns = {};

if (collectionDefinition === undefined)
if (!collectionDefinition)
throw new sdk.BadRequest(
`Couldn't find collection '${collection}' in the schema.`,
);
Expand All @@ -322,7 +322,7 @@ function parseQueryRequest(
const collectionObjectType =
collectionsSchema.objectTypes[collectionObjectBaseType];

if (collectionObjectType === undefined)
if (!collectionObjectType)
throw new sdk.InternalServerError(
`Couldn't find the schema of the object type: '${collectionObjectBaseType}'`,
);
Expand Down Expand Up @@ -419,8 +419,8 @@ function parseQueryRequest(
selectAsValue: false,
};

if (queryRequest.query.limit != null) {
if (queryRequest.query.offset != null) {
if (queryRequest.query.limit) {
if (queryRequest.query.offset) {
sqlGenCtx.offset = queryRequest.query.offset;
} else {
// The Azure Cosmos DB for NoSQL SQL syntax always requires an
Expand All @@ -431,10 +431,7 @@ function parseQueryRequest(
sqlGenCtx.limit = queryRequest.query.limit;
}

if (
queryRequest.query.order_by != null &&
queryRequest.query.order_by != undefined
) {
if (queryRequest.query.order_by) {
validateOrderBy(queryRequest.query.order_by, collectionObjectType);
sqlGenCtx.orderBy = queryRequest.query.order_by;
}
Expand Down Expand Up @@ -464,7 +461,7 @@ export async function executeQuery(
const collectionDefinition: schema.CollectionDefinition =
collectionsSchema.collections[collection];

if (collectionDefinition === undefined)
if (!collectionDefinition)
throw new sdk.BadRequest(
`Couldn't find collection '${collection}' in the schema.`,
);
Expand Down
2 changes: 1 addition & 1 deletion src/connector/sql/sqlGeneration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ export function getScalarType(column: Column): string {
return getNestedScalarType(column.nestedField);
}

if (column.type === undefined) {
if (!column.type) {
throw new sdk.BadRequest(`Couldn't find type of column: ${column.name}`);
} else {
switch (column.type.type) {
Expand Down

0 comments on commit b7ba0f7

Please sign in to comment.