MCPcopy Index your code
hub / github.com/loopbackio/loopback-next / isPrimaryKeyFlag

Function isPrimaryKeyFlag

packages/cli/lib/ast-helper.js:117–143  ·  view source on GitHub ↗
(idInitializer)

Source from the content-addressed store, hash-verified

115};
116
117function isPrimaryKeyFlag(idInitializer) {
118 const kindName = syntaxKindName(idInitializer.kind);
119
120 /* istanbul ignore if */
121 if (debug.enabled) {
122 debug(
123 'Checking primary key flag initializer, kind: %s node:',
124 kindName,
125 require('util').inspect(
126 {...idInitializer, parent: '[removed for brevity]'},
127 {depth: null},
128 ),
129 );
130 }
131
132 // {id: true}
133 if (kindName === 'TrueKeyword') return true;
134
135 // {id: number}
136 if (kindName === 'NumericLiteral') {
137 const ix = +idInitializer.text;
138 // the value must be a non-zero number, e.g. {id: 1}
139 return ix !== 0 && !isNaN(ix);
140 }
141
142 return false;
143}
144
145exports.getDataSourceConfig = function (fileContent) {
146 const ast = tsquery.ast(fileContent);

Callers 1

ast-helper.jsFile · 0.85

Calls 1

inspectMethod · 0.65

Tested by

no test coverage detected