我在服务器(Ubuntu14.04)中安装了MongoDB 3.0.1.我需要为MongoDB启用远程身份验证,以便注册用户只能看到它.一旦安装了Mongo,我就运行了这些命令:
> use admin
switched to db products
> db.createUser({user: "userAdmin", pwd: "admin1234", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]})
Run Code Online (Sandbox Code Playgroud)
这是我的/etc/mongod.conf":
dbpath = /var/lib/mongodb
logpath = /var/log/mongodb/mongod.log
logappend = true
port = 27017
bind_ip = 127.0.0.1,SERVER_IP
auth = true
Run Code Online (Sandbox Code Playgroud)
如果我尝试连接RoboMongo,我收到此消息
YES - Connected to SERVER_IP
NO - Authorization failed
Run Code Online (Sandbox Code Playgroud)
如果我尝试从我的浏览器访问它(http:// SERVER_IP:3000 /产品),我会收到以下消息:
null
Run Code Online (Sandbox Code Playgroud)
如果我从浏览器更改配置文件"auth = false",我可以看到这个(这是正确的)
[]
Run Code Online (Sandbox Code Playgroud)
但我无法登录,有人可以帮助我吗?
我有这个代码:
var labelsPrint= new Array();
var vector = labelsPrint.map((el) => el.id);
Run Code Online (Sandbox Code Playgroud)
IE11给我一个错误,因为丢失了数据.你知道另一种制作这个.map的方法吗?
我有这个代码:
document.getElementById(id).remove();
Run Code Online (Sandbox Code Playgroud)
但是,IE给我一个错误的功能.你知道另一种方法吗?
我尝试在我的后端创建一个函数来创建一个用户,我习惯于 Spring Boot、Hibernate、JPA、PostgreSQL……这是我的代码:
用户.java
@Entity
@Table(name = "users")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@NotNull
@NotBlank
@Size(max = 100)
@Column(name = "firstName")
private String name;
@NotNull
@NotBlank
@Size(max = 30)
@Column(name = "username", unique = true)
private String username;
@NotNull
@NotBlank
@Size(max = 150)
@Column(name = "password")
private String password;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "cityId", nullable = false)
@JsonIgnore
private City city;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "countryId", nullable = false)
@JsonIgnore
private Country …Run Code Online (Sandbox Code Playgroud) 我收到一个包含大量信息的JSON,但我想删除一个特定的数据,例如,如果我收到变量名,我想在我的数据库中添加我的JSON之前删除这个变量.这是我的功能POST:
app.post("/:coleccion", function (req, res, next) {
POST
if(req.body.name)
// Here I need delete "name" if I receive this variable <------
req.collection.insert(req.body, {}, function (e, result) {
if(e) return next(e);
res.send(result);
});
});
Run Code Online (Sandbox Code Playgroud) javascript ×3
node.js ×2
arrays ×1
express ×1
hashmap ×1
hibernate ×1
java ×1
jpa ×1
json ×1
mongodb ×1
removechild ×1
request ×1
rest ×1
robo3t ×1
spring-boot ×1