标签: populate

猫鼬:填充人口稠密的土地

我正在使用MongoDB作为我的应用程序的日志管理器,然后同步移动客户端.我在NodeJS中设置了这个模型:

var UserArticle = new Schema({
    date: { type: Number, default: Math.round((new Date()).getTime() / 1000) }, //Timestamp!
    user: [{type: Schema.ObjectId, ref: "User"}],
    article: [{type: Schema.ObjectId, ref: "Article"}],
    place: Number,    
    read: Number,     
    starred: Number,   
    source: String
});
mongoose.model("UserArticle",UserArticle);

var Log = new Schema({
    user: [{type: Schema.ObjectId, ref: "User"}],
    action: Number, // O => Insert, 1 => Update, 2 => Delete
    uarticle: [{type: Schema.ObjectId, ref: "UserArticle"}],
    timestamp: { type: Number, default: Math.round((new Date()).getTime() / 1000) }
});
mongoose.model("Log",Log);
Run Code Online (Sandbox Code Playgroud)

当我想要检索日志时,我使用以下代码:


var log = …
Run Code Online (Sandbox Code Playgroud)

populate mongoose mongodb node.js

18
推荐指数
3
解决办法
1万
查看次数

使用JavaFX中的数据库填充tableview

我开始学习javaFX,我需要使用数据库中的数据填充表.我在线阅读了很多代码,但我还没找到我想要的东西.我读过这篇文章,但我不知道如何实现最后一个函数.我读了一些其他代码来做到这一点,到目前为止这是我的一些代码:

@FXML private TableView<User> table;
@FXML private TableColumn<User, String> nameCol;
@FXML private TableColumn<User, String> emailCol;
private ObservableList<User> data;

public void initialize(URL location, ResourceBundle resources) {
    nameCol.setCellValueFactory(new PropertyValueFactory(“name”));
    emailCol.setCellValueFactory(new PropertyValueFactory(“email”));
    buildData();
}
public void buildData() {
        Connection connect = new Connection();
        Statement st = connect.Connect();
        data = FXCollections.observableArrayList();
        try {
            ResultSet rs = st.executeQuery("SELECT * FROM USER");
             while (rs.next()) {
                ObservableList<User> row = FXCollections.observableArrayList();
                for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
                    row.add(rs.getString(i));
                    System.out.println(row);
                }
                data.add(pol);
            } …
Run Code Online (Sandbox Code Playgroud)

java database javafx populate tableview

18
推荐指数
1
解决办法
5万
查看次数

如何设置默认组合框

所以我一直在寻找为我的组合框设置一个默认值.我发现了一些东西但它们似乎都没有用.

实际上,如果我创建一个简单的组合框并使用它,comboBox1.SelectedIndex = comboBox1.Items.IndexOf("something")但是一旦我动态生成组合框的内容,它就无法工作了.

这是我填充我的组合框(位于类的构造函数中);

        string command = "SELECT category_id, name FROM CATEGORY ORDER BY name";
        List<string[]> list = database.Select(command, false);

        cbxCategory.Items.Clear();

        foreach (string[] result in list)
        {
            cbxCategory.Items.Add(new ComboBoxItem(result[1], result[0]));
        }
Run Code Online (Sandbox Code Playgroud)

我似乎无法让它设置默认值,就像我放在cbxCategory.SelectedIndex = cbxCategory.Items.IndexOf("New")上面的代码下面,它将无法正常工作.

顺便说一句,WinForms.

先感谢您.

c# combobox populate winforms

17
推荐指数
1
解决办法
8万
查看次数

Pandas根据另一个数据框中的匹配列填充新的数据框列

我有一个df包含我的主要数据,其中有一百万rows.我的主要数据也有30个columns.现在我想在我的df被叫中添加另一列category.该categorycolumndf2其中包含约700 rows和两个其他columns将搭配2 columnsdf.

我开始设置一个indexin df2并且df将在帧之间匹配,但是其中一些indexin df2不存在df.

其余的列df2被称为AUTHOR_NAMECATEGORY.

df调用相关列AUTHOR_NAME.

一些AUTHOR_NAMEin df不存在,df2反之亦然.

我要的指令是:当indexdf同场比赛indexdf2,并titledf同场比赛titledf2,添加categorydf,否则在加的NaN category.

示例数据: …

python merge populate pandas

17
推荐指数
1
解决办法
4万
查看次数

使用对象列表填充Android Spinner

我正在使用用户对象填充我的微调器,以便稍后使用用户ID工作,但用户列表的显示显示我猜对象的地址.

所以我的问题是如何只显示对象的一个​​属性,在用户名的情况下,但仍然用整个对象填充微调器

这是我的代码:

User user1 = new User("user1",24);
User user2 = new User("user2",26);

// Creating adapter for spinner
List<User> users = new ArrayList<User>();
users.add(user1);
users.add(user2);

ArrayAdapter<User> dataAdapter = new ArrayAdapter<User>(this, 
    android.R.layout.simple_spinner_item, users);

// Drop down layout style - list view
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

Spinner _EmpSpinner =  null;
_EmpSpinner = (Spinner) findViewById(R.id.EmployeesSpinner); 

// attaching data adapter to spinner
_EmpSpinner.setAdapter(dataAdapter);
Run Code Online (Sandbox Code Playgroud)

这就是它显示的内容:

android populate spinner data-structures android-spinner

14
推荐指数
1
解决办法
2万
查看次数

如何知道何时完成Android ListView的填充

我有一个包含ListView的子Activity.此活动是从SQLite游标异步填充的.列表项包含TextView,RadioButton和普通Button.XML如下所示:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/rlCategoryListItemLayout" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content">
 <TextView android:id="@+id/tvCategoryListItemTitle" style="@style/uwLargeListItemLabelStyle" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_centerVertical="true" android:singleLine="true" android:text="This is a test note title" />
 <LinearLayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_alignParentRight="true" android:gravity="center_vertical">
  <RadioButton android:id="@+id/rdoCategoryListItemSelect" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginRight="10dip" />
  <Button android:id="@+id/btnCategoryListItemDelete" android:background="@drawable/delete_red" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" />
 </LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

我必须做一些逻辑来确定默认选择哪个RadioButton,并且在ListView已经加载之前我不能这样做.问题是,到目前为止我尝试过的所有事件(onCreate,onPostCreate,onResume,onWindowFocusChanged),ListView子计数为零.我也尝试在ArrayAdapter类中使用getView方法,但该方法被称为多个时间,并且ListView子计数每次都可能不同,从而导致意外结果.显然,这些事件在ListView完成填充其子项之前触发.

是否有我可以侦听的事件,或者其他一些方法来确定ListView何时完成填充并且可以通过编程方式修改其所有子代?

谢谢!

events android listview populate

13
推荐指数
2
解决办法
9727
查看次数

在init不起作用后用JSON填充select2

我正在尝试使用JSON数组填充select2元素; 但我无法得到它.

我有下一个数组:

data = [{"id":"Foo","text":"Foo"},{"id":"Bar","text":"Bar"}]
Run Code Online (Sandbox Code Playgroud)

我将select2初始化如下:

$("#selectElement").select2();
Run Code Online (Sandbox Code Playgroud)

我使用下一个代码填充:

$('#selectElement').select2('data', data, true);
Run Code Online (Sandbox Code Playgroud)

但不起作用,我不知道为什么.有人可以帮帮我吗?

编辑:我需要在select2的init之后填充(我从AJAX接收JSON)

我的意图是使用其他select2的AJAX搜索的JSON填充我的问题的select2.

一切都很好,除了populate(我在第一个格式的Selectiom方法中得到了这个JSON,但我不知道我可以用这个来填充第二个select2)

jquery json populate jquery-select2

12
推荐指数
1
解决办法
1万
查看次数

Mongoose:转换为ObjectId失败的值

我正在尝试在mongoose中指定我的数据库的模式.目前我这样做:

var Schema = mongoose.Schema;  
var today = new Date(2011, 11, 12, 0, 0, 0, 0);


var personSchema = new Schema({  
   _id : Number,
   name: { type: String, required: true },  
   tel: { type: String, required: true },  
   email: { type: String, required: true },
   newsitems: [{ type: Schema.Types.ObjectId, ref:'NewsItem'}]
});

var taskSchema = new Schema({ 
    _id: Number,
    description: { type: String, required: true },  
    startDate: { type: Date, required: true },
    newsitems: [{ type: Schema.Types.ObjectId, ref:'NewsItem'}]
});

var newsSchema …
Run Code Online (Sandbox Code Playgroud)

javascript populate mongoose mongodb node.js

10
推荐指数
2
解决办法
3万
查看次数

Mongoose查询填充的字段

   db.History.find({'_file.project': 'someproject' )
      .populate('_file', 'name reference project')
      .sort(sortField || '-created')
      .limit(max || 64)
      .exec(this);
Run Code Online (Sandbox Code Playgroud)

在这里,我试图在_file引用中找到与填充字段匹配的所有文档.似乎没有用.有可能这样吗?

我可以将项目字段复制到此对象,作为查询的解决方法,但我当然不是.

populate mongoose

10
推荐指数
1
解决办法
9382
查看次数

从列表中填充Combobox

Newb在这里,我正在制作一个有一个组合框的表格,它会显示几个Charlie Brown电视特价,您可以点击选择并查看描述,评级,运行时等.我很接近,但我在填充组合框方面不存在,我希望得到一些帮助和指导.我已经看过别人做过的几件事,但是我知识不足以从我迄今为止看到的内容中推断出答案.

现在我也在尝试:1.从你的加载方法获取列表2.循环它们3.访问我的组合框,用列表中的时间填充该框.

Form1.cs的

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.Globalization;//Used for Sting.ToUpperCase...
using System.Threading;

using System.Threading.Tasks;// Needed for Streaming...
using System.IO;// Needed for Streaming...


namespace a100___GUI___VideoStoreSelections
{
public partial class FormMovieLookUp : Form
{
    private const String FILE_NAME = "txt_movieDescriptions.txt";//connect to text file in debug

    private List<Listing> films { get; set; }

    public FormMovieLookUp()
    {
        InitializeComponent();
    }

    private void cmbMovieListingBox_SelectedIndexChanged(object sender, EventArgs e)
    {
        txtTitleBox.Text = cmbMovieListingBox.SelectedItem.ToString();
    } …
Run Code Online (Sandbox Code Playgroud)

c# combobox class list populate

10
推荐指数
2
解决办法
7万
查看次数