Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/388.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 是否将登录字段添加到数据库?_Javascript_Html_Mongodb_Meteor_Meteor Accounts - Fatal编程技术网

Javascript 是否将登录字段添加到数据库?

Javascript 是否将登录字段添加到数据库?,javascript,html,mongodb,meteor,meteor-accounts,Javascript,Html,Mongodb,Meteor,Meteor Accounts,我目前正在尝试创建一个字段,将用户插入的任何内容插入数据库。我目前正在尝试创建一个名为“UserRecords”的数据库,这样当他们提交表单时,它就会访问数据库,并用用户插入到字段中的内容更新“UserRecords”数据库。目前,我尝试连接的唯一字段是“地址”字段 这是我的tware/config.js文件: UserRecords = new Mongo.Collection("userrecords"); AccountsTemplates.configure({ // Beh

我目前正在尝试创建一个字段,将用户插入的任何内容插入数据库。我目前正在尝试创建一个名为“UserRecords”的数据库,这样当他们提交表单时,它就会访问数据库,并用用户插入到字段中的内容更新“UserRecords”数据库。目前,我尝试连接的唯一字段是“地址”字段

这是我的tware/config.js文件:

UserRecords = new Mongo.Collection("userrecords");

AccountsTemplates.configure({

    // Behavior
    confirmPassword: true,
    enablePasswordChange: true,
    forbidClientAccountCreation: false,
    overrideLoginErrors: true,
    sendVerificationEmail: true,
    lowercaseUsername: false,
    focusFirstInput: true,

    // Appearance
    showAddRemoveServices: false,
    showForgotPasswordLink: true,
    showLabels: true,
    showPlaceholders: true,
    showResendVerificationEmailLink: true,

    // Client-side Validation
    continuousValidation: false,
    negativeFeedback: false,
    negativeValidation: true,
    positiveValidation: true,
    positiveFeedback: true,
    showValidating: true,

    // Privacy Policy and Terms of Use
    privacyUrl: 'privacy',
    termsUrl: 'terms-of-use',

    // Redirects
    homeRoutePath: '/map',
    redirectTimeout: 4000,
});

AccountsTemplates.addField({  
    _id: "address",
    type: "text",
    displayName: "Address",
    placeholder: {
        signUp: "Your Address"
    },
});

AccountsTemplates.addField({
    _id: "pilotorcustomer",
    type: "radio",
    displayName: "Are You A Pilot Or Looking For A Service",
    required: true,
    select: [
        {
        text: "Pilot",
        value: "aa",
      }, {
        text: "Customer",
        value: "bb",
      },
    ],
});
如果有人想查看整个文件,可以通过以下链接在github上查看:

提前谢谢大家,


Stephen

好的,所以我解决了这个问题,在AccountTemplates.addField中添加了一个全局变量,然后创建一个函数调用varialeb将其插入数据库

这是完成的config.js代码:

UserRecords = new Mongo.Collection("userrecords");

insertDatabase = function (address) {
    UserRecords.insert({
        Address: address._id,
    });
};

AccountsTemplates.configure({

    // Behavior
    confirmPassword: true,
    enablePasswordChange: true,
    forbidClientAccountCreation: false,
    overrideLoginErrors: true,
    sendVerificationEmail: true,
    lowercaseUsername: false,
    focusFirstInput: true,

    // Appearance
    showAddRemoveServices: false,
    showForgotPasswordLink: true,
    showLabels: true,
    showPlaceholders: true,
    showResendVerificationEmailLink: true,

    // Client-side Validation
    continuousValidation: false,
    negativeFeedback: false,
    negativeValidation: true,
    positiveValidation: true,
    positiveFeedback: true,
    showValidating: true,

    // Privacy Policy and Terms of Use
    privacyUrl: 'privacy',
    termsUrl: 'terms-of-use',

    // Redirects
    homeRoutePath: '/map',
    redirectTimeout: 4000,
});

address = AccountsTemplates.addField({  
    _id: "address",
    type: "text",
    displayName: "Address",
    required: true,
    placeholder: {
        signUp: "Your Address"
    },
});

AccountsTemplates.addField({
    _id: "pilotorcustomer",
    type: "radio",
    displayName: "Are You A Pilot Or Looking For A Service",
    required: true,
    select: [
        {
        text: "Pilot",
        value: "aa",
      }, {
        text: "Customer",
        value: "bb",
      },
    ],
});