gpt4 book ai didi

node.js - 如何将自定义 ObjectId 添加到解析服务器对象?

转载 作者:行者123 更新时间:2023-12-04 10:43:44 25 4
gpt4 key购买 nike

向我的 User 添加数据时遇到问题Mongoose 的类,以后无法通过解析 API 更新它。

我发现这是因为 Mongoose 使用 ObjectId_id field 和 parse 只使用普通字符串作为 ObjectId .

问题是如何在 Parse Server 中将我的自定义唯一纯字符串设置为 ObjectId对象创建?

最佳答案

你可以这样做:

const cryptoUtils = require('parse-server/lib/cryptoUtils');
const id = cryptoUtils.newObjectId();
来源: https://github.com/parse-community/parse-server/blob/master/src/cryptoUtils.js

关于node.js - 如何将自定义 ObjectId 添加到解析服务器对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59814654/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com