猫鼬必需的真实验证不起作用

时间:2018-09-09 04:36:01

标签: node.js mongodb mongoose

我正在尝试使用nodejs并使用猫鼬将文档保存到mangoDB,但是我对我设置为required的名称的验证:true无法正常工作。虽然我尚未设置名称字段,但文档已保存。我在代码中遗漏了什么吗?

import socket                   # Import socket module

s = socket.socket()             # Create a socket object
host = socket.gethostname()     # Get local machine name
port = 60000                    # Reserve a port for your service.

s.connect((host, port))
fileNeeded = input("What File do you need, please enter the name:")
s.send(fileNeeded.encode())

fileToBeSaved = input("Enter file name to save requested file")

with open(fileToBeSaved, 'wb') as f:
    print ('file opened')
    while True:
        print('receiving data...')
        data = s.recv(1024)
        print((data))
        if not data:
            break
        # write data to a file
        f.write(data)

f.close()
print('Successfully got the file')
s.close()
print('connection closed')

2 个答案:

答案 0 :(得分:1)

您可能要仔细检查“要求”为“必需”

答案 1 :(得分:1)

在这里,progressBar.setVisibility(View.GONE); 的拼写错误。从更正 requiredrequried