SyntaxError: Unexpected token, expected , (10:10)

SyntaxError: Unexpected token, expected , (10:10)



I'm practicing JavaScript code with this. https://rationalappdev.com/api-backend-with-nodejs-express-and-mongodb-for-react-native-apps/



I'm trying to change DB part with my own code, but when I run this at the terminal,
enter image description here



this error occurs.



and this is baby.js's code.


import mongoose, Schema from 'mongoose';

var babySchema = new Schema(
info:
size:
width: number, height: number ,
faceCount: number
,
faces:
[ roi :
x: number, y: number, width: number, height: number ,
landmark:
leftEye: x: number, y: number ,
rightEye: x: number, y: number ,
nose: x: number, y: number ,
leftMouth: x: number, y: number ,
rightMouth: x: number, y: number ,
gender: value: String, confidence: number ,
age: value: String, confidence: number ,
emotion: value: String, confidence: number ,
pose: value: String, confidence: number
]
);

export default mongoose.mode('baby', babySchema);






Try changing faces: [ .. ] to faces ...

– dustytrash
Sep 18 '18 at 16:14


faces: [ .. ]


faces ...






is an array. there are no associative arrays in js, you probably want an object:

– Xatenev
Sep 18 '18 at 16:15







1 Answer
1



You can use the : only in objects to assign a value and not in an array. So you need to wrap roi: ... in roi: :


:


roi: ...


roi:


var babySchema = new Schema(
info:
size:
width: number, height: number ,
faceCount: number
,
faces:
[ roi :
x: number, y: number, width: number, height: number ,
landmark:
leftEye: x: number, y: number ,
rightEye: x: number, y: number ,
nose: x: number, y: number ,
leftMouth: x: number, y: number ,
rightMouth: x: number, y: number ,
gender: value: String, confidence: number ,
age: value: String, confidence: number ,
emotion: value: String, confidence: number ,
pose: value: String, confidence: number
]
);



If the attribute faces should not be an array, just remove the around the roi object.


faces



roi






That's also possible, but I don't know, if he wants an array of faces or not

– Batajus
Sep 18 '18 at 16:22






Thanks! it works. 😂

– Jinne
Sep 18 '18 at 16:52






@jinne if worked then mark response as answer

– Er. Amit Joshi
Sep 18 '18 at 18:14



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

How do I collapse sections of code in Visual Studio Code for Windows?

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ